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 genuinely contended — exactly the case the
limiter exists for. 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).
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RateLimit
impl RefUnwindSafe for RateLimit
impl Send for RateLimit
impl Sync for RateLimit
impl Unpin for RateLimit
impl UnsafeUnpin for RateLimit
impl UnwindSafe for RateLimit
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more