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§
- Client
IpRate Key - An
InputToRateKeyextractor keying on the client IP address, resolved viaclient_ip:Forwardedinformation (populated by e.g. forwarded-header or PROXY-protocol layers) wins over the transport peer address (SocketInfo). - Keyed
Rate Policy - A limit
Policythat 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. - Missing
Rate Key - serve aborted: no rate key could be derived for input
Traits§
- Input
ToRate Key - Derives the
RateKeyof an input for aKeyedRatePolicy. - RateKey
- A key to rate limit on: the bucket-map key of a
KeyedRatePolicy.