pub struct Consumer { /* private fields */ }Expand description
Folds a group’s per-node stats broadcasts into one merged view.
Scope an origin::Consumer to a single group (e.g. .stats/<pid>) and
hand it here; each Self::traffic / Self::sessions call opens its own
announce cursor and subscribes to that track on every node broadcast in the
group, summing the cumulative counters per key. Traffic is sticky: a node
dropping out (its broadcast unannounces or its reader ends) keeps its last
contribution, so a relay that returns with its boot-lifetime counters
intact never looks like new traffic. Only a genuine per-node counter
regression (a restarted relay) regresses the merged counter, the same reset
contract a single node’s own restart follows. Presence is not sticky: a
departed node stops counting sessions immediately.
Implementations§
Source§impl Consumer
impl Consumer
Sourcepub fn new(origin: Consumer, config: Config) -> Self
pub fn new(origin: Consumer, config: Config) -> Self
Wrap an origin consumer, ideally already scoped to one group. config’s
prefix and depth must match the producing side.
Sourcepub fn traffic(&self, tier: &Tier, role: Role) -> TrafficConsumer
pub fn traffic(&self, tier: &Tier, role: Role) -> TrafficConsumer
A merged reader over the traffic track for (tier, role), folding every
node broadcast in the group. Nodes are subscribed lazily as they announce,
so this returns without a handshake.
Sourcepub fn sessions(&self, tier: &Tier) -> SessionsConsumer
pub fn sessions(&self, tier: &Tier) -> SessionsConsumer
A merged reader over the sessions track for tier; see Self::traffic.