Skip to main content

Crate ratelimit

Crate ratelimit 

Source
Expand description

Bounded sliding-window throttles for authentication attempts.

Pure state plus an injected clock, so tests drive the time axis instead of sleeping. Deliberately in-process: a shared backend belongs behind Bucket’s interface, not woven through its callers, and until one exists the effective limit is replicas × limit — which is why the surfaces using this run single-replica.

Structs§

Bucket
A sliding-window counter per key, holding at most Limits::capacity keys.
Limits
Throttle shape: how many attempts, over what window, across how many keys.
SystemClock
Delegates to Instant::now.

Enums§

Decision

Traits§

Clock
“What time is it now”, injected so tests need not sleep.