pub struct Deduplicator { /* private fields */ }Expand description
Deduplicates requests by key within a TTL window.
§Guarantees
- Deterministic: same key always maps to the same result
- Thread-safe via
Arc<Mutex<_>> - Entries expire after
ttl
Implementations§
Source§impl Deduplicator
impl Deduplicator
Sourcepub fn check_and_register(
&self,
key: &str,
) -> Result<DeduplicationResult, AgentRuntimeError>
pub fn check_and_register( &self, key: &str, ) -> Result<DeduplicationResult, AgentRuntimeError>
Check whether key is new, cached, or in-flight.
Marks the key as in-flight if it is new.
Sourcepub fn check(
&self,
key: &str,
ttl: Duration,
) -> Result<DeduplicationResult, AgentRuntimeError>
pub fn check( &self, key: &str, ttl: Duration, ) -> Result<DeduplicationResult, AgentRuntimeError>
Check deduplication state for a key with a per-call TTL override.
Marks the key as in-flight if it is new. Ignores the stored TTL and uses
ttl instead for expiry checks.
Sourcepub fn dedup_many(
&self,
requests: &[(&str, Duration)],
) -> Result<Vec<DeduplicationResult>, AgentRuntimeError>
pub fn dedup_many( &self, requests: &[(&str, Duration)], ) -> Result<Vec<DeduplicationResult>, AgentRuntimeError>
Check deduplication state for multiple keys at once.
Returns results in the same order as requests.
Each entry is (key, ttl) — same signature as check.
Trait Implementations§
Source§impl Clone for Deduplicator
impl Clone for Deduplicator
Source§fn clone(&self) -> Deduplicator
fn clone(&self) -> Deduplicator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Deduplicator
impl RefUnwindSafe for Deduplicator
impl Send for Deduplicator
impl Sync for Deduplicator
impl Unpin for Deduplicator
impl UnsafeUnpin for Deduplicator
impl UnwindSafe for Deduplicator
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