pub struct StatsTable { /* private fields */ }Expand description
The table. Feed it samples; read it per key or in aggregate.
Bounded. A CLI runs for --window seconds and exits, so an unbounded
map was fine; a GUI left open overnight on a bus carrying content-addressed
or per-request keys would grow one entry per key forever. The table
therefore keeps at most DEFAULT_MAX_KEYS entries, evicting the
least-recently-seen first — the keys that stopped publishing are the ones a
live view has least use for — and counts every eviction, so a shrinking
key set is never mistaken for a quiet bus (RFC 09 §5.1).
Implementations§
Source§impl StatsTable
impl StatsTable
pub fn new() -> Self
Sourcepub fn with_capacity(max_keys: usize) -> Self
pub fn with_capacity(max_keys: usize) -> Self
A table bounded at max_keys entries.
Sourcepub fn unwatched(&self) -> u64
pub fn unwatched(&self) -> u64
Keys retired because no active watch covers them any more
(retire_unwatched).
The third O6 category, deliberately distinct from
evicted (“chose to forget under the bound”) and the
broadcast’s dropped (“could not keep up”): this one is “stopped
looking, by request” — and a key set that shrinks because the user
unwatched a subtree must say so, or it reads as a quieting bus.
Sourcepub fn retire_unwatched(&mut self, gone: &str, kept: &[String]) -> usize
pub fn retire_unwatched(&mut self, gone: &str, kept: &[String]) -> usize
Retire every key that gone covers and no selector in kept still
covers, counting them under unwatched. Returns
how many were retired. Selectors that fail to parse as key
expressions cover nothing (gone) / keep nothing (kept).
Sourcepub fn record(
&mut self,
key: &str,
payload_len: usize,
sn: Option<u32>,
now: Instant,
latency_us: Option<i64>,
)
pub fn record( &mut self, key: &str, payload_len: usize, sn: Option<u32>, now: Instant, latency_us: Option<i64>, )
Record one sample. now is injected for deterministic tests;
latency_us is the pre-computed skewed latency (#119) — None for
an unstamped sample, which is counted, not defaulted.
pub fn get(&self, key: &str) -> Option<&KeyStats>
pub fn iter(&self) -> impl Iterator<Item = (&str, &KeyStats)>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Debug for StatsTable
impl Debug for StatsTable
Auto Trait Implementations§
impl Freeze for StatsTable
impl RefUnwindSafe for StatsTable
impl Send for StatsTable
impl Sync for StatsTable
impl Unpin for StatsTable
impl UnsafeUnpin for StatsTable
impl UnwindSafe for StatsTable
Blanket Implementations§
Source§impl<Source> AccessAs for Source
impl<Source> AccessAs for Source
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