Skip to main content

Pusher

Type Alias Pusher 

Source
pub type Pusher = Endpoint<Push>;
Expand description

The sending half of Push/Pull.

Aliased Type§

pub struct Pusher { /* private fields */ }

Implementations§

Source§

impl Pusher

Source

pub async fn connect(&self, url: &str) -> Result<(), Error>

Connects to weida://host:port/path.

The address is kept: a lost connection is redialled by the runtime under crate::RuntimeConfig::reconnect, and Pusher::events reports it.

Source

pub fn disconnect(&self, url: &str) -> bool

Forgets a dialled address; see Peer::disconnect.

Source

pub fn peer_count(&self) -> usize

Number of connected peers.

Source

pub fn connection_stats(&self) -> Vec<ConnectionStats>

One record per live connection, labelled by the URL as dialled; see Peer::connection_stats.

Source

pub fn events(&self) -> PeerEvents

The event stream of this pusher’s addresses; see Peer::events.

Source

pub fn dropped(&self) -> u64

Bodies the outbox discarded; see Peer::dropped.

Source

pub async fn open(&self, meta: TransferMeta) -> Result<OutgoingTransfer, Error>

Opens a one-way transfer to the next peer, round-robin.

Use this rather than Pusher::send when the transport receipt matters: OutgoingTransfer::finish hands back a crate::Delivery that resolves once the peer’s transport holds every byte. The stream is the application’s: with every peer down this waits for the redial, and a stream on a connection that dies fails with ConnectionLost and is not reopened by anyone but the caller.

Source

pub async fn send(&self, body: &[u8]) -> Result<(), Error>

Sends body as one message: the runtime owns it from this call.

Pipeline semantics: the delivery receipt is discarded, so a push costs no round trip and reports only failures the local side already knows about. With a live peer the body is written at once; with none it is held in the outbox and written once a peer is back, in order, and a full outbox applies the configured backpressure (Peer::send). Callers who want the receipt use Pusher::open and await crate::Delivery::delivered themselves.

Source

pub async fn send_with( &self, meta: TransferMeta, body: &[u8], ) -> Result<(), Error>

Like Pusher::send, with explicit metadata.