#[non_exhaustive]pub struct Config {
pub origin: Option<Producer>,
pub prefix: PathOwned,
pub node: Option<PathOwned>,
pub interval: Duration,
pub depth: usize,
pub linger: Duration,
}Expand description
Settings for a Producer. Construct with Config::new and chain
the with_* setters (e.g.
Config::new().with_origin(origin).with_prefix(".foo")), then hand it
to Producer::new.
With no origin set the resulting producer is a no-op: its registry is
disabled (bumps are dropped) and no task spawns. Call
Config::with_origin to publish.
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<Producer>Origin the stats broadcasts are created on.
When None, Producer::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). Also the registry’s exclude prefix, so serving a
stats broadcast doesn’t generate more stats.
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 publish task waits between drains. Default 1s.
depth: usizeHow many leading broadcast-path segments to use as a grouping key.
Default 0 publishes one <prefix>/node/<node> broadcast carrying every
path. 1 publishes one broadcast per first segment at
<prefix>/<group>/node/<node>, and larger values include more leading
segments. Group broadcasts are announced while their group has live traffic,
plus the Self::linger; at depth 0, the single broadcast stays
announced for the producer’s life.
linger: DurationHow long a group broadcast stays announced after its group’s last entry leaves. Default 5 minutes.
A group that returns within the linger keeps its broadcast, so a viewer
leaving and another arriving causes no unannounce and re-announce across
the mesh. While it lingers empty, every track reads {}. Zero
unannounces on the first drain the group is empty. Unused at depth 0.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new() -> Self
pub fn new() -> Self
A config with default settings: no origin (no-op), .stats prefix, 1s
interval, and no node suffix. Call Self::with_origin to actually
publish.
Sourcepub fn with_origin(self, origin: impl Into<Option<Producer>>) -> Self
pub fn with_origin(self, origin: impl Into<Option<Producer>>) -> Self
Set the origin to publish the stats broadcast on. Without this the producer 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 publish interval (default 1s).
Sourcepub fn with_node(self, node: impl Into<Option<PathOwned>>) -> Self
pub fn with_node(self, node: impl Into<Option<PathOwned>>) -> Self
Set the node suffix (default none). An empty path is treated as unset.
Sourcepub fn with_depth(self, depth: usize) -> Self
pub fn with_depth(self, depth: usize) -> Self
Set the grouping depth (default 0, a single broadcast). See Self::depth.
Sourcepub fn with_linger(self, linger: Duration) -> Self
pub fn with_linger(self, linger: Duration) -> Self
Set how long an empty group broadcast stays announced (default 5
minutes). See Self::linger.