Skip to main content

Module rate_limit

Module rate_limit 

Source
Expand description

Token bucket rate limiting middleware. Token bucket rate limiter implemented as a tower Layer/Service.

Requests are counted per caller: the token’s sub (else jti, else its agent) when the request is authenticated, otherwise the peer IP address. The layer must sit inside the auth middleware so it sees the caller.

Structs§

RateLimitService
RateLimiter
Shared rate limiter state.

Constants§

DEFAULT_BURST
Default bucket size (MENTEDB_RATE_LIMIT_BURST).
DEFAULT_PER_SEC
Default refill per second (MENTEDB_RATE_LIMIT_PER_SEC).