Wraith. RateLimit
(Wraith v0.1.0)
View Source
A small token bucket in ETS. check(scope, key, limit, per_ms) lets
limit hits through per per_ms window for one key (an IP, a visitor
id, an email) and answers :ok or {:error, retry_after_ms}. Fixed
windows, one row per (scope, key); a sweep every minute drops stale rows.
Scopes and their defaults (limits/0) are what the plugs and LiveViews
use; tests may relax them with config :wraith, :rate_limits.
Summary
Functions
Returns a specification to start this module under a supervisor.
Forget a key (tests, or after a successful login).
Functions
@spec check(atom(), term()) :: :ok | {:error, non_neg_integer()}
@spec check(atom(), term(), pos_integer(), pos_integer()) :: :ok | {:error, non_neg_integer()}
Returns a specification to start this module under a supervisor.
See Supervisor.
Forget a key (tests, or after a successful login).