pub struct SseHub { /* private fields */ }Expand description
Thread-safe sharded multi-topic Server-Sent Events pub/sub hub with Last-Event-ID replay.
Implementations§
Source§impl SseHub
Inherent implementation of SseHub.
impl SseHub
Inherent implementation of SseHub.
Sourcepub fn get_config(&self) -> &SseConfig
pub fn get_config(&self) -> &SseConfig
Sourcepub fn publish<T>(&self, topic: T, event: SseEvent) -> Result<u64, SseError>
pub fn publish<T>(&self, topic: T, event: SseEvent) -> Result<u64, SseError>
Publishes an event to topic, assigning a monotonic id if absent and appending to replay history.
§Arguments
T- Topic name convertible intoString.SseEvent- Event to fan out to active subscribers.
§Returns
Result<u64, SseError>- Assigned sequence identifier, orSseError::TopicLimitReached.
Sourcepub fn subscribe<T>(
&self,
topic: T,
last_event_id: Option<&str>,
) -> Result<SseSubscription, SseError>
pub fn subscribe<T>( &self, topic: T, last_event_id: Option<&str>, ) -> Result<SseSubscription, SseError>
Subscribes to topic, replaying retained events newer than last_event_id via binary search.
§Arguments
T- Topic name convertible intoString.Option<&str>- OptionalLast-Event-IDheader value for catch-up replay.
§Returns
Result<SseSubscription, SseError>- Active subscription orSseError::TopicLimitReached.
Sourcepub fn remove_topic(&self, topic: &str) -> bool
pub fn remove_topic(&self, topic: &str) -> bool
Sourcepub fn topic_names(&self) -> Vec<String>
pub fn topic_names(&self) -> Vec<String>
Returns all currently active topic names across all shards.
§Returns
Vec<String>- Snapshot of active topic names.
Sourcepub fn topic_count(&self) -> usize
pub fn topic_count(&self) -> usize
Returns the number of active topics currently tracked by this hub in O(1).
§Returns
usize- Count of tracked topics.
Trait Implementations§
Auto Trait Implementations§
impl Forget for SseHub
impl Freeze for SseHub
impl Move for SseHub
impl RefUnwindSafe for SseHubwhere
Atomic<usize>: RefUnwindSafe,
Atomic<u64>: RefUnwindSafe,
RwLock<HashMap<Arc<str>, Arc<TopicState>, BuildHasherDefault<FxHasher>>>: RefUnwindSafe,
Mutex<HashMap<(Id, u64), Arc<SseHeartbeatWheel>>>: RefUnwindSafe,
impl Send for SseHub
impl Sync for SseHub
impl Unpin for SseHub
impl UnsafeUnpin for SseHubwhere
*const ArcInner<SseHubInner> is !null: UnsafeUnpin,
PhantomData<ArcInner<SseHubInner>>: UnsafeUnpin,
impl UnwindSafe for SseHubwhere
Arc<SseHubInner>: UnwindSafe,
Blanket Implementations§
impl<T> AnySend for T
impl<T> AnySendClone for T
impl<T> AnySendSync for T
impl<T> AnySendSyncClone for T
impl<T> AnySync for T
impl<T> AnySyncClone for T
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