Skip to main content

Route

Struct Route 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§hops: OriginList

The 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: u64

The 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: bool

Whether 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

Source

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.

Source

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.

Source

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.

Source

pub fn with_hops(self, hops: OriginList) -> Self

Replace the hop chain.

Source

pub fn with_cost(self, cost: u64) -> Self

Set the cost: lower wins among routes serving the same broadcast.

Source

pub fn with_announce(self, announce: bool) -> Self

Set whether the broadcast is announced via this route.

Trait Implementations§

Source§

impl Clone for Route

Source§

fn clone(&self) -> Route

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Route

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Route

Source§

fn default() -> Route

Returns the “default value” for a type. Read more
Source§

impl Eq for Route

Source§

impl PartialEq for Route

Source§

fn eq(&self, other: &Route) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Route

Auto Trait Implementations§

§

impl Freeze for Route

§

impl RefUnwindSafe for Route

§

impl Send for Route

§

impl Sync for Route

§

impl Unpin for Route

§

impl UnsafeUnpin for Route

§

impl UnwindSafe for Route

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more