Struct PerSenderTracker
pub struct PerSenderTracker { /* private fields */ }Expand description
Per-sender sliding-window rate limiter. The bucket map is Arc-shared so cloned policies (SubAgents) consume from the same budgets.
Implementations§
Source§impl PerSenderTracker
impl PerSenderTracker
Sourcepub const GLOBAL_KEY: &'static str = "__global__"
pub const GLOBAL_KEY: &'static str = "__global__"
Bucket key used when no per-sender context is available (cron, CLI).
Sourcepub fn record_for_current(&self, max: u32) -> bool
pub fn record_for_current(&self, max: u32) -> bool
Record one action for the current sender. Returns true if allowed
(count after recording <= max), false if budget exhausted.
Sourcepub fn record_within(&self, key: &str, max: u32) -> bool
pub fn record_within(&self, key: &str, max: u32) -> bool
Record one action for key. Allows the action when count == max (≤ max);
blocks and returns false when count > max.
Sourcepub fn is_limited_for_current(&self, max: u32) -> bool
pub fn is_limited_for_current(&self, max: u32) -> bool
Check if the current sender is at or over the limit (without recording).
pub fn is_exhausted(&self, key: &str, max: u32) -> bool
Trait Implementations§
Source§impl Clone for PerSenderTracker
impl Clone for PerSenderTracker
Source§impl Debug for PerSenderTracker
impl Debug for PerSenderTracker
Auto Trait Implementations§
impl Freeze for PerSenderTracker
impl !RefUnwindSafe for PerSenderTracker
impl Send for PerSenderTracker
impl Sync for PerSenderTracker
impl Unpin for PerSenderTracker
impl UnsafeUnpin for PerSenderTracker
impl !UnwindSafe for PerSenderTracker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more