Skip to main content

Relay

Trait Relay 

Source
pub trait Relay: Send + Sync {
    // Required methods
    fn cursor(&self) -> Cursor;
    fn resume(&self, from: Cursor, limit: usize) -> Resumed;
    fn ingest(
        &self,
        source: &str,
        entry: RelayedEntry,
    ) -> Result<u64, IngestError>;
}
Expand description

A capability of a bus (Bus::relay), on top of its Journal: the events of relayable points served to another process from a cursor, and the events another process serves taken in as if published here.

A point is relayable when its declaration gives it a codec (PointDecl::relayable); only its events cross. The transport (a socket, a pipe, an RPC) is the application’s: a relay reads and takes entries, it does not move them.

What an implementation promises:

  • A bus that offers Relay offers Journal.
  • Relay::resume returns the relayable entries after the cursor, in number order, each written by its point’s codec, and the cursor to resume from. A cursor of another run returns the run’s entries from its start with Lost::Restarted; a cursor whose next entries left the window returns the kept ones with Lost::Gap. Cursor::START loses nothing.
  • Relay::ingest records a relayed entry in this journal with its source: a point declared here is decoded with its codec and delivered to its listeners like an entry published here; a kind not declared here is kept with its text only and delivered to no one. The cause is the sender’s number, kept as it came.
  • Entries taken in are not served again by Relay::resume: two processes relaying to each other do not echo.

Required Methods§

Source

fn cursor(&self) -> Cursor

Where a reader that starts now stands: this journal’s run and its last number.

Source

fn resume(&self, from: Cursor, limit: usize) -> Resumed

The relayable entries after from, at most limit.

Source

fn ingest(&self, source: &str, entry: RelayedEntry) -> Result<u64, IngestError>

Takes in an entry relayed from source; its number in this journal.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§