Skip to main content

Module rate

Module rate 

Available on crate feature net only.
Expand description

Keyed (per-client) rate limiting.

KeyedRatePolicy is the per-key sibling of RatePolicy: instead of one shared token bucket, every key — typically the client IP, see ClientIpRateKey — gets its own lazily-created bucket, stored in a bounded, idle-evicting cache.

Structs§

ClientIpRateKey
An InputToRateKey extractor keying on the client IP address, resolved via client_ip: Forwarded information (populated by e.g. forwarded-header or PROXY-protocol layers) wins over the transport peer address (SocketInfo).
KeyedRatePolicy
A limit Policy that rate limits inputs per key: every key gets its own token bucket, lazily created on first use and stored in a bounded, idle-evicting cache.
MissingRateKey
serve aborted: no rate key could be derived for input

Traits§

InputToRateKey
Derives the RateKey of an input for a KeyedRatePolicy.
RateKey
A key to rate limit on: the bucket-map key of a KeyedRatePolicy.