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
RelayoffersJournal. Relay::resumereturns 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 withLost::Restarted; a cursor whose next entries left the window returns the kept ones withLost::Gap.Cursor::STARTloses nothing.Relay::ingestrecords 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§
Sourcefn cursor(&self) -> Cursor
fn cursor(&self) -> Cursor
Where a reader that starts now stands: this journal’s run and its last number.
Sourcefn resume(&self, from: Cursor, limit: usize) -> Resumed
fn resume(&self, from: Cursor, limit: usize) -> Resumed
The relayable entries after from, at most limit.
Sourcefn ingest(&self, source: &str, entry: RelayedEntry) -> Result<u64, IngestError>
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".