pub struct RateLimit { /* private fields */ }Expand description
A per-callsite token bucket: up to capacity events per window, then
suppression with a count carried into the first event of the next
window.
const-constructible for use in statics. Under a poison storm every
pinned pipeline thread hits the same limiter once per failing record,
so the exact-accounting mutex is contended. To keep steady-state
suppression off the shared lock, a relaxed-atomic fast path
short-circuits while the window stays saturated: a single relaxed load
of saturated plus a deadline compare, no mutex. The mutex path remains
the source of truth for allow decisions and window rolls; suppressed
events counted on the fast path are folded back in at the next roll, so
the carried suppressed count is exact in practice (best-effort under
concurrent rolls).