ProtoRune. HTTPClient. RateLimiter
(proto_rune v0.3.0)
Copy Markdown
Tracks outgoing requests per key (usually the target host) in fixed one-minute windows and throttles callers once a configurable limit is reached.
Counts are kept in an ETS table so no process needs to be started. When the limit for the current window is exceeded, the caller sleeps until the next window starts.
Summary
Functions
Registers a request for key, sleeping until the next window when the
per-minute limit for the current window has been reached.
Functions
Registers a request for key, sleeping until the next window when the
per-minute limit for the current window has been reached.
Options
:requests_per_minute- the limit forkey.nilorfalsedisables throttling and tracking.:now_fun- zero-arity function returning the current time in milliseconds. Defaults toSystem.monotonic_time/1.:sleep_fun- one-arity function used to wait, defaults toProcess.sleep/1.
Returns :ok once the request may proceed.