#[non_exhaustive]pub struct StatsConfig {
pub origin: Option<OriginProducer>,
pub prefix: PathOwned,
pub node: Option<PathOwned>,
pub interval: Duration,
}Expand description
Settings for a Stats aggregator. Construct with StatsConfig::new
and chain the with_* setters (e.g.
StatsConfig::new().with_origin(origin).with_prefix(".foo")), then hand it
to Stats::new.
With no origin set the resulting aggregator is a no-op: bumps are dropped
and no task spawns. Call StatsConfig::with_origin to publish.
Distinct from the relay’s clap-derived StatsConfig, which holds the raw
CLI/TOML knobs and resolves into one of these.
#[non_exhaustive] so new knobs can land without breaking call sites; build
via StatsConfig::new rather than a struct literal.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.origin: Option<OriginProducer>Origin that receives the stats broadcast’s publish_broadcast calls.
When None, Stats::new spawns no task and publishes nothing.
prefix: PathOwnedTop-level path stats are published under (default .stats). The full
advertised path is <prefix>/node/<node> (or <prefix>/node when
node is unset).
node: Option<PathOwned>Node suffix that disambiguates broadcasts from different relays sharing a
cluster origin. Set this on every node in multi-relay deployments. May be
multi-segment (e.g. sjc/1, sjc/2) so a region with multiple hosts can
nest under a shared region key. An empty path is treated as unset.
Default none.
interval: DurationHow long the snapshot task waits between publishes. Default 1s.
Implementations§
Source§impl StatsConfig
impl StatsConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
A config with default settings: no origin (no-op), .stats prefix, 1s
snapshot interval, and no node suffix. Call Self::with_origin to
actually publish.
Sourcepub fn with_origin(self, origin: impl Into<Option<OriginProducer>>) -> Self
pub fn with_origin(self, origin: impl Into<Option<OriginProducer>>) -> Self
Set the origin to publish the stats broadcast on. Without this the aggregator is a no-op.
Sourcepub fn with_prefix(self, prefix: impl Into<PathOwned>) -> Self
pub fn with_prefix(self, prefix: impl Into<PathOwned>) -> Self
Override the top-level prefix (default .stats).
Sourcepub fn with_interval(self, interval: Duration) -> Self
pub fn with_interval(self, interval: Duration) -> Self
Override the snapshot interval (default 1s).
Trait Implementations§
Source§impl Clone for StatsConfig
impl Clone for StatsConfig
Source§fn clone(&self) -> StatsConfig
fn clone(&self) -> StatsConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more