pub struct InstrumentCache { /* private fields */ }Expand description
A cache of instrument metadata with a caller-driven refresh clock.
The refresh decision takes the current time as an argument rather than reading a hidden clock, so staleness logic is deterministic and testable.
Implementations§
Source§impl InstrumentCache
impl InstrumentCache
Sourcepub fn new() -> InstrumentCache
pub fn new() -> InstrumentCache
An empty cache.
Sourcepub fn replace(
&mut self,
instruments: impl IntoIterator<Item = Instrument>,
now_ms: i64,
)
pub fn replace( &mut self, instruments: impl IntoIterator<Item = Instrument>, now_ms: i64, )
Replace the cache contents with a freshly fetched set, stamping the fetch time (milliseconds since the Unix epoch).
Sourcepub fn get(&self, symbol: &Symbol) -> Option<&Instrument>
pub fn get(&self, symbol: &Symbol) -> Option<&Instrument>
Look up an instrument by symbol.
Sourcepub fn needs_refresh(&self, now_ms: i64, ttl_ms: i64) -> bool
pub fn needs_refresh(&self, now_ms: i64, ttl_ms: i64) -> bool
Whether the cache should be refreshed: never fetched, or older than
ttl_ms relative to now_ms.
Trait Implementations§
Source§impl Debug for InstrumentCache
impl Debug for InstrumentCache
Source§impl Default for InstrumentCache
impl Default for InstrumentCache
Source§fn default() -> InstrumentCache
fn default() -> InstrumentCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for InstrumentCache
impl RefUnwindSafe for InstrumentCache
impl Send for InstrumentCache
impl Sync for InstrumentCache
impl Unpin for InstrumentCache
impl UnsafeUnpin for InstrumentCache
impl UnwindSafe for InstrumentCache
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