Expand description
Rate limiter — token bucket implementation for DoS protection.
Limits request rates per client (or per any arbitrary key). Uses the token bucket algorithm: tokens refill at a fixed rate up to a capacity ceiling. Each request consumes one token.
§OCP design
New rate-limiting algorithms (sliding window, leaky bucket) are
added by implementing the RateLimiter trait — no existing code
is modified.
Structs§
- Noop
Rate Limiter - A rate limiter that always allows. Useful for testing and development environments where rate limiting is disabled.
- Token
Bucket Config - Configuration for a token bucket rate limiter.
- Token
Bucket Rate Limiter - Token bucket rate limiter with per-key buckets.
Traits§
- Rate
Limiter - Trait for rate limiters. Implementations decide whether a request
from
key(typically a client ID or IP) should be allowed.