rmcafee / discord_ex

Discord Elixir Library
MIT License
47 stars 13 forks source link

handle Rate Limits in some "good" way #17

Open Marqin opened 8 years ago

Marqin commented 8 years ago

RATE LIMITS docs (it's on github, link on web docs is broken)

Discord's dev request for lib developers to handle Rate Limiting properly

Marqin commented 8 years ago

So, the simple way to implent:

We could have some "global state" implemented via Agent (or process) that is registered to atom name. And now, when geting REST reposnse we upgrade that "state" to current rate limit info. And when doing REST request we can:

if curr_time() < RateLimit.get(:rate_limit, "refresh_time") and RateLimit.get(:rate_limit, "req_left") == 0 do
  {:error, "You have been blocked by RateLimit feature."
else
  # send our request
end
Marqin commented 8 years ago

I could start working on it when we agree on some architecture.

Marqin commented 8 years ago

rate limiting:

HTTP

WS

Game Status:

Gateway connection: