pub struct BatchCidResolver {
pub cache_ttl: Duration,
pub max_batch_size: usize,
pub stats: Arc<BatchResolverStats>,
/* private fields */
}Expand description
Fields§
§cache_ttl: DurationTime-to-live applied to newly stored cache entries
max_batch_size: usizeMaximum number of pending items consumed per drain_batch call
stats: Arc<BatchResolverStats>Operational statistics
Implementations§
Source§impl BatchCidResolver
impl BatchCidResolver
Sourcepub fn with_config(cache_ttl: Duration, max_batch_size: usize) -> Self
pub fn with_config(cache_ttl: Duration, max_batch_size: usize) -> Self
Create a resolver with custom TTL and batch size.
Sourcepub fn queue_lookup(&self, cid: &str) -> LookupHandle
pub fn queue_lookup(&self, cid: &str) -> LookupHandle
Queue a CID for resolution.
Returns a LookupHandle the caller can use to track the request.
If the CID is already in the cache the item is still queued; callers
should call get_cached first if they want to avoid duplicate work.
Sourcepub fn drain_batch(&self) -> Vec<PendingLookup>
pub fn drain_batch(&self) -> Vec<PendingLookup>
Atomically drain up to max_batch_size pending lookups.
Returns the drained items in FIFO order. Increments
total_batches_drained only when at least one item is returned.
Sourcepub fn record_result(&self, cid: &str, providers: Vec<String>)
pub fn record_result(&self, cid: &str, providers: Vec<String>)
Store a resolved provider list for cid.
Any existing entry (including unexpired ones) is overwritten.
Sourcepub fn get_cached(&self, cid: &str) -> Option<Vec<String>>
pub fn get_cached(&self, cid: &str) -> Option<Vec<String>>
Return the cached provider list for cid if it has not expired.
Sourcepub fn evict_expired(&self)
pub fn evict_expired(&self)
Remove all cache entries that have exceeded their TTL.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Return the number of CIDs currently in the pending queue.
Sourcepub fn cache_size(&self) -> usize
pub fn cache_size(&self) -> usize
Return the number of entries currently held in the cache
(expired entries are counted until evict_expired is called).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BatchCidResolver
impl RefUnwindSafe for BatchCidResolver
impl Send for BatchCidResolver
impl Sync for BatchCidResolver
impl Unpin for BatchCidResolver
impl UnsafeUnpin for BatchCidResolver
impl UnwindSafe for BatchCidResolver
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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>
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