pub struct MembershipHandle { /* private fields */ }Expand description
Changes the streams of a running SupervisedUsdmWs.
Each stream is routed to its path’s connection, opening it if this is the path’s first stream and closing it when its last leaves. The membership is a set: subscribing a stream twice holds it once, and counting references is the caller’s job.
A change is recorded before it is sent. During a path’s outage it is
answered Ok at once, and the replay applies it; so is a change whose
connection fails under it, or one the server leaves unanswered for
stale_after, which replaces the connection. A change that arrives while
a connect or a replay is in flight waits for that attempt. Calls are served
one at a time across paths, so a change for a healthy path can wait behind
another path’s attempt.
A call fails when the server refuses it (UsdmWsError::Refused), when it
would pass 1024 streams on a path (UsdmWsError::TooManyStreams, nothing
sent), when the first connect of a path it opens fails in a way retrying
cannot fix (UsdmWsError::Connect), or when the client has stopped
(UsdmWsError::Stopped). Its cause is the error a path stopped on once
the router has that path’s stop; a call in flight when the path stops can
get Stopped { cause: None }. A subscription of more than 200 names is sent
in batches, so one refused part-way leaves the earlier batches applied.
A call waits for the path’s task, which takes no change while the consumer leaves 1024 events unread. Make membership changes from a task other than the one draining the stream, or keep draining while they run.
Implementations§
Source§impl MembershipHandle
impl MembershipHandle
Sourcepub async fn subscribe(
&self,
streams: impl IntoIterator<Item = StreamName>,
) -> Result<(), UsdmWsError>
pub async fn subscribe( &self, streams: impl IntoIterator<Item = StreamName>, ) -> Result<(), UsdmWsError>
Subscribe to more streams.
Sourcepub async fn unsubscribe(
&self,
streams: impl IntoIterator<Item = StreamName>,
) -> Result<(), UsdmWsError>
pub async fn unsubscribe( &self, streams: impl IntoIterator<Item = StreamName>, ) -> Result<(), UsdmWsError>
Unsubscribe from streams. A stream not subscribed is ignored.