pub struct DedupFilter { /* private fields */ }Expand description
Time-bounded deduplication filter.
Tracks recently seen IDs and automatically expires entries
older than the configured TTL. Uses an injectable Clock
(WEFT-113) so tests can advance TTL without sleeping.
Implementations§
Source§impl DedupFilter
impl DedupFilter
Sourcepub fn new(ttl: Duration, max_entries: usize) -> Self
pub fn new(ttl: Duration, max_entries: usize) -> Self
Create a new dedup filter with the given TTL and max capacity.
Binds the production RealClock.
Sourcepub fn with_clock(
ttl: Duration,
max_entries: usize,
clock: Arc<dyn Clock>,
) -> Self
pub fn with_clock( ttl: Duration, max_entries: usize, clock: Arc<dyn Clock>, ) -> Self
Create a dedup filter with an injectable Clock.
Sourcepub fn default_mesh() -> Self
pub fn default_mesh() -> Self
Create a dedup filter with default settings (60s TTL, 10000 entries).
Sourcepub fn check_and_insert(&mut self, id: &str) -> bool
pub fn check_and_insert(&mut self, id: &str) -> bool
Check if an ID has been seen before. If not, mark it as seen.
Returns true if this is a new (not duplicate) message.
Sourcepub fn is_duplicate(&self, id: &str) -> bool
pub fn is_duplicate(&self, id: &str) -> bool
Check if an ID has been seen (without inserting).
Auto Trait Implementations§
impl !RefUnwindSafe for DedupFilter
impl !UnwindSafe for DedupFilter
impl Freeze for DedupFilter
impl Send for DedupFilter
impl Sync for DedupFilter
impl Unpin for DedupFilter
impl UnsafeUnpin for DedupFilter
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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