pub struct SubscriberSet { /* private fields */ }Expand description
The set of sessions currently listening.
Reads are lock-free: the subscriber list is behind an ArcSwap for the
same reason the primitive set is, and a publish walks a Vec of Arcs
that no writer can mutate.
Implementations§
Source§impl SubscriberSet
impl SubscriberSet
Sourcepub fn all(&self) -> Vec<Arc<Subscriber>>
pub fn all(&self) -> Vec<Arc<Subscriber>>
The current subscribers, as one owned snapshot.
Sourcepub fn add(&self, subscriber: Subscriber)
pub fn add(&self, subscriber: Subscriber)
Adds a session’s standing interest.
Sourcepub fn remove_by_sink(&self, sink: &Arc<dyn DynFrameSink>) -> usize
pub fn remove_by_sink(&self, sink: &Arc<dyn DynFrameSink>) -> usize
Drops every subscriber whose sink is sink, by identity.
By pointer identity rather than by session id because a session id is the thing this module is not allowed to log, and comparing two of them to decide who to remove would be a use of one anyway. The sink is the connection, and a connection is what a disconnect closes.
Returns how many were dropped, so a caller can assert that a disconnect actually unsubscribed rather than assuming it.
Sourcepub async fn announce(
&self,
snapshot: &Snapshot,
kinds: &[PrimitiveKind],
) -> Fanout
pub async fn announce( &self, snapshot: &Snapshot, kinds: &[PrimitiveKind], ) -> Fanout
Tells the eligible subscribers that kinds changed in snapshot.
A subscriber is told when both hold: it registered for a kind this publish touched, and its own negotiated profile permits the notification. The kind test comes from the publish; the profile test comes from the subscriber. Neither can be derived from the other, which is why both are here.
The subscriber list is loaded once, so a subscriber that disconnects mid-fan-out is either told or not told but never told twice, and a subscriber that joins mid-fan-out is not told about a change it could not have observed.