Skip to main content

ClusterRelay

Trait ClusterRelay 

Source
pub trait ClusterRelay:
    Send
    + Sync
    + 'static {
    // Required methods
    fn locate<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 StreamKey,
    ) -> Pin<Box<dyn Future<Output = Result<Option<NodeAddr>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn pull<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 StreamKey,
        origin: &'life2 NodeAddr,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn announce<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 StreamKey,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn withdraw<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 StreamKey,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn ensure_mirrored<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 StreamKey,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Origin/edge relay contract. Implement to federate streams across nodes: an edge that lacks a stream locally locates its origin and pulls it; an origin announces what it has.

Required Methods§

Source

fn locate<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 StreamKey, ) -> Pin<Box<dyn Future<Output = Result<Option<NodeAddr>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Find a node currently serving key, if any (e.g. via the control plane).

Source

fn pull<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 StreamKey, origin: &'life2 NodeAddr, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Begin relaying key from origin into the local engine, returning once the local mirror is publishing.

Source

fn announce<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 StreamKey, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Advertise that this node serves key so edges can discover it.

Source

fn withdraw<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 StreamKey, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Withdraw a previous announce when the stream ends.

Provided Methods§

Source

fn ensure_mirrored<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 StreamKey, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Demand policy on top of the locate/pull mechanism: make key available locally, returning true if a mirror is now (or already) present and false if no origin serves it.

A host serving a play/WHEP/HLS request calls this so it doesn’t have to hand-write “locate, then pull if not already local.” Implementations should de-duplicate concurrent callers for the same key (single-flight) so a burst of N simultaneous viewer requests for a not-yet-mirrored stream triggers one pull, not N racing start_publish calls.

The default is a plain locate + pull with no coalescing or locality check; NetworkRelay overrides it with a locality fast-path and single-flight.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ClusterRelay for InProcessRelay

Available on crate feature cluster only.