Skip to main content

byteflow/scheduler/mailbox/
metrics.rs

1// Docs ratchet: public items here predate `missing_docs`. Delete this
2// allow once they are documented; new files get the lint by default.
3#![allow(missing_docs)]
4
5/// Per-mailbox counters (Relaxed atomics would over-synchronize a hot
6/// inbox). Updated only while the mailbox mutex is held — same critical
7/// section as enqueue / park — then copied out for host scrapes.
8#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
9pub struct MailboxStats {
10    pub enqueued: u64,
11    pub dequeued: u64,
12    /// Total refusals under [`super::OverflowPolicy::Reject`], whichever
13    /// bound was hit.
14    pub rejected: u64,
15    /// Subset of [`Self::rejected`] caused by the byte budget rather than
16    /// the hop count. `rejected - rejected_byte_limit` is therefore the
17    /// hop-count share — the two have different remedies, so an operator
18    /// needs to tell them apart.
19    pub rejected_byte_limit: u64,
20    pub dropped_newest: u64,
21    pub dropped_oldest: u64,
22    /// Hops queued **right now** (occupancy, not a counter).
23    pub queued_messages: usize,
24    /// Bytes charged to the queued hops right now. Compare against the
25    /// configured [`super::MailboxBytes`] to see how close an inbox is to
26    /// its budget before it starts refusing.
27    pub queued_bytes: usize,
28}