Expand description
Request-count rate limiter for GraphQL API targets with pluggable algorithms.
Two strategies are supported via RateLimitStrategy:
-
SlidingWindow— limits outgoing requests tomax_requestsin any rollingwindowduration. Before each requestrate_limit_acquireis called; it records the current timestamp and sleeps until the oldest in-window request expires if the window is already full. -
TokenBucket— refills tokens at a steady rate (max_requests / window); short bursts are absorbed by the bucket capacity before the rate is enforced. Computes the exact wait time required to accumulate the next token instead of sleeping speculatively.
A server-returned Retry-After value can be applied via
rate_limit_retry_after, which imposes a hard block until the indicated
instant irrespective of the active algorithm.
Operates in parallel with graphql_throttle
(leaky-bucket cost throttle). Both can be active simultaneously.
Re-exports§
pub use crate::ports::graphql_plugin::RateLimitConfig;pub use crate::ports::graphql_plugin::RateLimitStrategy;
Structs§
- Request
Rate Limit - Shareable, cheaply-cloneable handle to a per-plugin sliding-window limiter.
Functions§
- parse_
retry_ after - Parse an integer
Retry-Aftervalue from a header string. - rate_
limit_ acquire - Sleep until a request slot is available within the rolling window, then record the slot.
- rate_
limit_ retry_ after - Record a server-returned
Retry-Afterdelay.