pub struct SseBroadcaster { /* private fields */ }Expand description
Generic, string-keyed pub/sub fan-out for SSE-style event delivery.
Applications map their own session ids at the boundary. Non-blocking sends drop on a full subscriber channel so a slow consumer cannot stall the broadcaster.
Implementations§
Source§impl SseBroadcaster
impl SseBroadcaster
Sourcepub fn subscribe(&self, app_key: &str) -> (String, Receiver<SseEvent>)
pub fn subscribe(&self, app_key: &str) -> (String, Receiver<SseEvent>)
Registers a new subscriber for app_key.
Returns (subscriber_id, receiver). The channel is buffered (cap 100) so a
transient slow consumer does not drop events immediately.
Sourcepub fn unsubscribe(&self, app_key: &str, subscriber_id: &str)
pub fn unsubscribe(&self, app_key: &str, subscriber_id: &str)
Removes a subscriber by id and closes its channel.
Sourcepub fn broadcast(&self, app_key: &str, event: SseEvent)
pub fn broadcast(&self, app_key: &str, event: SseEvent)
Sends an event to all subscribers for app_key.
Non-blocking: a full subscriber channel is skipped (drop-on-full) so one slow consumer cannot block the others.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SseBroadcaster
impl RefUnwindSafe for SseBroadcaster
impl Send for SseBroadcaster
impl Sync for SseBroadcaster
impl Unpin for SseBroadcaster
impl UnsafeUnpin for SseBroadcaster
impl UnwindSafe for SseBroadcaster
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