pub struct WebSocketChannelManager { /* private fields */ }Expand description
WebSocket-based notification channel. The manager maintains the
list of subscriptions and emits serialised change notifications on
a tokio::sync::broadcast channel that upstream HTTP servers
attach WebSocket tasks to.
Implementations§
Source§impl WebSocketChannelManager
impl WebSocketChannelManager
pub fn new() -> Self
Sourcepub fn with_heartbeat(self, interval: Duration) -> Self
pub fn with_heartbeat(self, interval: Duration) -> Self
Override the heartbeat interval (default 30s).
Sourcepub fn heartbeat_interval(&self) -> Duration
pub fn heartbeat_interval(&self) -> Duration
Internal test hook.
Sourcepub async fn subscribe(&self, topic: &str, base_url: &str) -> Subscription
pub async fn subscribe(&self, topic: &str, base_url: &str) -> Subscription
Register a new WebSocket subscription. Returns the
receive_from URL the client should connect to.
Sourcepub async fn unsubscribe(&self, id: &str)
pub async fn unsubscribe(&self, id: &str)
Remove a subscription.
Sourcepub fn stream(&self) -> Receiver<ChangeNotification>
pub fn stream(&self) -> Receiver<ChangeNotification>
Subscribe to the broadcast stream. Each delivered message is a
pre-serialised ChangeNotification that the transport layer
writes to the WebSocket frame.
Sourcepub async fn active_subscriptions(&self) -> usize
pub async fn active_subscriptions(&self) -> usize
Number of active subscriptions.
Sourcepub async fn pump_from_storage(
self,
rx: Receiver<StorageEvent>,
pod_base: String,
)
pub async fn pump_from_storage( self, rx: Receiver<StorageEvent>, pod_base: String, )
Attach this manager to a stream of storage events. Each event is translated into an Activity Streams notification and broadcast to every connected client whose subscription topic covers the event path.
Trait Implementations§
Source§impl Clone for WebSocketChannelManager
impl Clone for WebSocketChannelManager
Source§fn clone(&self) -> WebSocketChannelManager
fn clone(&self) -> WebSocketChannelManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for WebSocketChannelManager
impl Default for WebSocketChannelManager
Source§impl Notifications for WebSocketChannelManager
impl Notifications for WebSocketChannelManager
Source§fn subscribe<'life0, 'async_trait>(
&'life0 self,
subscription: Subscription,
) -> Pin<Box<dyn Future<Output = Result<(), PodError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe<'life0, 'async_trait>(
&'life0 self,
subscription: Subscription,
) -> Pin<Box<dyn Future<Output = Result<(), PodError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn unsubscribe<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), PodError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn unsubscribe<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), PodError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn publish<'life0, 'life1, 'async_trait>(
&'life0 self,
_topic: &'life1 str,
notification: ChangeNotification,
) -> Pin<Box<dyn Future<Output = Result<(), PodError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn publish<'life0, 'life1, 'async_trait>(
&'life0 self,
_topic: &'life1 str,
notification: ChangeNotification,
) -> Pin<Box<dyn Future<Output = Result<(), PodError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
topic.