Skip to main content

Module rate_limiter

Module rate_limiter 

Source
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§

NoopRateLimiter
A rate limiter that always allows. Useful for testing and development environments where rate limiting is disabled.
TokenBucketConfig
Configuration for a token bucket rate limiter.
TokenBucketRateLimiter
Token bucket rate limiter with per-key buckets.

Traits§

RateLimiter
Trait for rate limiters. Implementations decide whether a request from key (typically a client ID or IP) should be allowed.