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 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.
pub async fn ack(&self, key: &str) -> Result<()>
pub async fn depth(&self, id: &str) -> Result<usize>
pub fn router(self) -> Router
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Broker
impl !UnwindSafe for Broker
impl Freeze for Broker
impl Send for Broker
impl Sync for Broker
impl Unpin for Broker
impl UnsafeUnpin for Broker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more