pub struct EventThrottler {
last_report_time: Arc<Mutex<HashMap<String, Instant>>>,
throttle_duration: Duration,
}Expand description
Event throttler to prevent spam from frequent position updates.
Tracks the last report time for each item and ensures reports are only sent at most once per throttle duration (default 30 seconds).
Fields§
§last_report_time: Arc<Mutex<HashMap<String, Instant>>>§throttle_duration: DurationImplementations§
Source§impl EventThrottler
impl EventThrottler
Sourcepub fn with_duration(duration: Duration) -> Self
pub fn with_duration(duration: Duration) -> Self
Creates a new EventThrottler with custom interval
Sourcepub fn should_report(&self, item_id: &str) -> bool
pub fn should_report(&self, item_id: &str) -> bool
Checks if enough time has elapsed since the last report for this item
Sourcepub fn mark_reported(&self, item_id: &str)
pub fn mark_reported(&self, item_id: &str)
Marks the item as reported at the current time
Sourcepub fn clear_item(&self, item_id: &str)
pub fn clear_item(&self, item_id: &str)
Removes a specific item from tracking
Trait Implementations§
Source§impl Clone for EventThrottler
impl Clone for EventThrottler
Auto Trait Implementations§
impl Freeze for EventThrottler
impl RefUnwindSafe for EventThrottler
impl Send for EventThrottler
impl Sync for EventThrottler
impl Unpin for EventThrottler
impl UnsafeUnpin for EventThrottler
impl UnwindSafe for EventThrottler
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>
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.