pub struct SSEBroadcaster { /* private fields */ }Expand description
Lock-free SSE broadcaster using DashMap
All operations are non-blocking using DashMap for client tracking and tokio unbounded channels for message passing.
Implementations§
Source§impl SSEBroadcaster
impl SSEBroadcaster
Sourcepub fn new() -> SSEBroadcaster
pub fn new() -> SSEBroadcaster
Create a new broadcaster with no connected clients.
Sourcepub fn register_client(&self, id: Uuid) -> UnboundedReceiver<SseEvent>
pub fn register_client(&self, id: Uuid) -> UnboundedReceiver<SseEvent>
Register a new client (lock-free)
Sourcepub fn unregister_client(&self, id: &Uuid)
pub fn unregister_client(&self, id: &Uuid)
Unregister a client (lock-free)
Sourcepub fn send_to_client(
&self,
client_id: &Uuid,
event: SseEvent,
) -> Result<(), String>
pub fn send_to_client( &self, client_id: &Uuid, event: SseEvent, ) -> Result<(), String>
Send event to specific client (lock-free)
Sourcepub fn active_clients(&self) -> u64
pub fn active_clients(&self) -> u64
Get active client count (atomic read)
Sourcepub fn total_events(&self) -> u64
pub fn total_events(&self) -> u64
Get total events broadcasted (atomic read)
Trait Implementations§
Source§impl Default for SSEBroadcaster
impl Default for SSEBroadcaster
Source§fn default() -> SSEBroadcaster
fn default() -> SSEBroadcaster
Returns the “default value” for a type. Read more
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request