Skip to main content

PendingReports

Struct PendingReports 

Source
pub struct PendingReports { /* private fields */ }
Expand description

Coalescing per-PV pending-timestamp map shared between every shard worker (incl. their spawn_blocking late-success closures) and the single global flush owner.

Why a shared map instead of an mpsc channel? With a channel, a slow flush owner causes the buffer to fill and try_send drops happen — for a PV that goes silent right after a dropped report, the registry’s last_event is permanently under-committed. With a coalescing map keyed by PV, every shard call is an entry().and_modify().or_insert() that always succeeds; concurrent updates from different shards never lose data because the map is bounded by PV count (typical: thousands), not by sample rate (typical: 100k/s).

Coalescing semantics. A successful append for (pv, ts) upserts the entry to max(current, ts). A stale late-success report (e.g. from a spawn_blocking task that finished after shard already wrote a newer sample) does NOT clobber a newer committed value.

Implementations§

Source§

impl PendingReports

Source

pub fn new() -> Self

Source

pub fn report(&self, pv: &str, ts: SystemTime)

Coalescing report. If pv already has a newer timestamp, no-op. Always succeeds — this is the channel-replacement invariant that makes silent-PV under-commit impossible.

Source

pub fn snapshot(&self) -> HashMap<String, SystemTime>

Snapshot the entire map for a flush cycle. Returns a owned HashMap; the shared map stays intact so concurrent shards can keep reporting during the flush.

Source

pub fn remove_committed(&self, committed: &HashMap<String, SystemTime>)

Remove entries whose CURRENT value still equals what we committed. If a concurrent shard advanced an entry to a newer ts after the snapshot, leave it alone — the next flush will pick it up.

Source

pub fn remove_failed(&self, failed: &[String])

Unconditionally remove every failed PV’s entry from the pending map, regardless of its current timestamp.

Why unconditional. The storage’s loss queue carries only PV names — it cannot tell us whether a concurrent shard’s post-snapshot report was for bytes that ARE on disk (e.g., a fresh writer opened after eviction) versus bytes that are also gone. The matching remove_committed path can leave a post-snapshot entry behind, and the next clean flush would commit it — turning a “PV’s bytes were lost” report into a last_event lie.

The trade-off: a brand-new sample whose bytes truly DID reach disk after the loss event gets dropped from this commit cycle. Future samples re-populate pending and the registry catches up. Under-commit is the safe direction; over-commit is never acceptable.

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Trait Implementations§

Source§

impl Default for PendingReports

Source§

fn default() -> PendingReports

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more