Failed-login bookkeeping per peer address.
A peer is locked once it has limit failures inside window_ms. Failures older
than the window are forgotten, and a success clears the peer.
throttle = Drafter.Accounts.Throttle.new(limit: 5, window_ms: 900_000)
throttle = Drafter.Accounts.Throttle.failed(throttle, {10, 0, 0, 7}, now)
Drafter.Accounts.Throttle.locked?(throttle, {10, 0, 0, 7}, now)
Summary
Functions
Record a failure for peer at millisecond time now.
Whether peer has reached the limit inside the window ending at now.
A throttle with no failures recorded.
Forget peer's failures.
Types
@type peer() :: term()
@type t() :: %Drafter.Accounts.Throttle{ failures: %{required(peer()) => [integer()]}, limit: pos_integer(), window_ms: pos_integer() }
Functions
Record a failure for peer at millisecond time now.
Whether peer has reached the limit inside the window ending at now.
A throttle with no failures recorded.
Options
:limit- failures inside the window that lock a peer. Default5.:window_ms- how long a failure counts, in milliseconds. Default900_000.
Forget peer's failures.