#[non_exhaustive]pub struct Route {
pub hops: OriginList,
pub cost: u64,
pub announce: bool,
/* private fields */
}Expand description
The path a broadcast takes to reach this origin, and how preferable it is.
Unlike Info, the route is dynamic: it changes when the serving session fails
over, the upstream topology shifts, or the publisher re-advertises itself.
Publish a change with Producer::set_route and observe one with
Consumer::route_changed; downstream sessions forward updates as a restart
on the wire, so route churn never looks like a new broadcast.
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.hops: OriginListThe chain of origins the broadcast has traversed, oldest first. Each relay
appends its own crate::Origin when forwarding; used for loop detection
and as the selection tie-break.
cost: u64The cost of pulling the broadcast via this route, accumulated per link: lower wins, with ties broken by hop length and then a deterministic hash.
The original publisher seeds it with its production cost (zero for a live publish, something large for a standby that would have to start working, like a cold transcoder), and each link adds its own configured price as the announcement crosses it, so a route over a metered backbone ranks worse than an equal-length one within a datacenter. The accumulation restarts at zero at any node actively carrying the broadcast: those upstream legs already exist and are not re-paid by one more subscriber, so the sum is the cost of the transfers a subscription would newly cause.
Carried on the wire from lite-06; older peers always report zero, leaving the hop-count tie-break as the effective metric exactly as before.
announce: boolWhether the broadcast should be announced: advertised to consumers via
crate::origin::Consumer::announced while this is the best route. A
non-announced broadcast stays reachable by exact path for subscribes and
fetches (e.g. serving cached or on-demand content), so toggling this via
Producer::set_route announces or unannounces without touching the
broadcast itself. Defaults to false.
Implementations§
Source§impl Route
impl Route
Sourcepub fn new() -> Self
pub fn new() -> Self
An unannounced direct route: no hops, best cost.
The broadcast is reachable only by its exact path, so subscribers must already
know it exists. Use announced to advertise it instead.
Sourcepub fn announced() -> Self
pub fn announced() -> Self
An announced direct route: no hops, best cost.
The broadcast is advertised to subscribers via
crate::origin::Consumer::announced while this is the best route, on top of
staying reachable by exact path. Use new to keep it unadvertised.
Sourcepub fn with_hop(self, origin: Origin) -> Result<Self, TooManyOrigins>
pub fn with_hop(self, origin: Origin) -> Result<Self, TooManyOrigins>
Append a hop to the chain, oldest first.
Fails with crate::TooManyOrigins once the chain is full, the same limit
the wire enforces.
Sourcepub fn with_hops(self, hops: OriginList) -> Self
pub fn with_hops(self, hops: OriginList) -> Self
Replace the hop chain.
Sourcepub fn with_cost(self, cost: u64) -> Self
pub fn with_cost(self, cost: u64) -> Self
Set the cost: lower wins among routes serving the same broadcast.
Sourcepub fn with_announce(self, announce: bool) -> Self
pub fn with_announce(self, announce: bool) -> Self
Set whether the broadcast is announced via this route.