A rate limit definition: a resource identity plus its sliding window and limit.
Build one with new/2 and pass it to the GlobalRateLimiter functions.
The whole struct identifies the tracked consumption group. The same resource with a different window or limit is tracked independently, and changing a limit's window or limit value starts a fresh consumption history.
Summary
Functions
Builds a limit that allows :limit consumptions within any sliding :window
milliseconds.
Types
@type t() :: %GlobalRateLimiter.Limit{ limit: non_neg_integer(), resource: term(), window: pos_integer() }
Functions
@spec new(term(), window: pos_integer(), limit: non_neg_integer()) :: t()
Builds a limit that allows :limit consumptions within any sliding :window
milliseconds.
The resource may be any Erlang term. Include every dimension that should have an independent limit.
iex> GlobalRateLimiter.Limit.new({:password_challenge, "192.0.2.10"}, window: 60_000, limit: 3)
%GlobalRateLimiter.Limit{resource: {:password_challenge, "192.0.2.10"}, window: 60_000, limit: 3}