pub struct Broker { /* private fields */ }Implementations§
Source§impl Broker
impl Broker
pub fn new(store: Store, cap: usize) -> Self
Sourcepub fn announce(&self, key: String, announcement: Value, now: u64)
pub fn announce(&self, key: String, announcement: Value, now: u64)
Record a presence announcement under a per-session key (pubkey#session_id,
or a bare pubkey for a sessionless legacy announcement). Prunes expired
entries; the announcement is stored verbatim (the bus never inspects it
beyond the routing key).
Sourcepub fn unregister(&self, key: &str)
pub fn unregister(&self, key: &str)
Immediately drop a session’s presence (a graceful close), so a peer learns it’s really gone rather than waiting out the TTL. Unsigned and best-effort: the bus verifies nothing, and a still-live session simply re-announces on its next heartbeat, so a spurious unregister is self-healing.
Sourcepub fn roster(&self, now: u64) -> Vec<Value>
pub fn roster(&self, now: u64) -> Vec<Value>
The retained announcements, each stamped with an unsigned age_ms (how long
since its last refresh) so the client can classify it live vs. away. The
announcement’s signed fields are untouched — age_ms is additive and ignored
by signature verification.
Sourcepub async fn enqueue(&self, to: &str, payload: Value, ts: u64) -> Result<()>
pub async fn enqueue(&self, to: &str, payload: Value, ts: u64) -> Result<()>
Enqueue for to: persist, enforce the cap (drop oldest), wake a waiter.
Sourcepub async fn recv(
&self,
id: &str,
wait: Duration,
) -> Result<Option<(Envelope, String)>>
pub async fn recv( &self, id: &str, wait: Duration, ) -> Result<Option<(Envelope, String)>>
Wait up to wait for the oldest un-acked message for id. Returns the
envelope and its ack key; the message stays in the store until ack.