pub struct RateTracker { /* private fields */ }Expand description
Thread-safe in-memory rate tracker.
Tracks action timestamps per agent DID using sliding windows. Not persistent — resets on process restart (by design; DATs are short-lived and rate limits are best-effort).
Implementations§
Source§impl RateTracker
impl RateTracker
Sourcepub fn record_action(&self, agent_did: &str)
pub fn record_action(&self, agent_did: &str)
Record an action for the given agent.
Sourcepub fn get_counts(&self, agent_did: &str) -> (u64, u64, u64)
pub fn get_counts(&self, agent_did: &str) -> (u64, u64, u64)
Get current rate counts for an agent: (hourly, daily, concurrent).
Sourcepub fn acquire_concurrent(&self, agent_did: &str)
pub fn acquire_concurrent(&self, agent_did: &str)
Increment the concurrent operation count for an agent.
Sourcepub fn release_concurrent(&self, agent_did: &str)
pub fn release_concurrent(&self, agent_did: &str)
Decrement the concurrent operation count for an agent.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RateTracker
impl RefUnwindSafe for RateTracker
impl Send for RateTracker
impl Sync for RateTracker
impl Unpin for RateTracker
impl UnsafeUnpin for RateTracker
impl UnwindSafe for RateTracker
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