- Notifications
You must be signed in to change notification settings - Fork1
Ratekeeper is a library for scheduling rate-limited actions.
License
NotificationsYou must be signed in to change notification settings
whitered/ratekeeper
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Ratekeeper is a library for scheduling rate-limited actions.It supports complex rate limits and estimates time left to resetting limits.
Addratekeeper
as dependency inmix.exs
defdepsdo[{:ratekeeper,"~> 0.2"}]end
Limits can be set in config:
config:ratekeeper,:limits,%{"myapi.org"=>[{1000,5},{60_000,100}]}
or at runtime:
Ratekeeper.add_limit"myapi.org",1000,5Ratekeeper.add_limit"myapi.org",60_000,100
This sets limits to5 requests per 1 second and100 requests per minute.
Appoint a request to rate limited api:
caseRatekeeper.register("myapi.org",10_000)donil->raise"Rate limits exceeded, request not allowed in next 10 seconds"delay->:timer.sleep(delay)MyApi.do_request()end
Full documentation can be found athttps://hexdocs.pm/ratekeeper.
About
Ratekeeper is a library for scheduling rate-limited actions.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.