pub struct MembershipHandle { /* private fields */ }Expand description
Changes the streams of a running SupervisedSpotWs.
The connection is opened for the first stream and closed when the 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 an 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. Changes are sent no faster than
one per 500 ms.
A call fails when the server refuses it (SpotWsError::Refused), when it
would pass 1024 streams (SpotWsError::TooManyStreams, nothing sent),
when the first connect of a connection it opens fails in a way retrying
cannot fix (SpotWsError::Connect), or when the client has stopped
(SpotWsError::Stopped). Its cause is the error the client stopped on
once the router has that stop; a call in flight when it stops can get
Stopped { cause: None }. A request carries up to 1024 names, so a
subscription is never split.
A call waits for the connection’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<(), SpotWsError>
pub async fn subscribe( &self, streams: impl IntoIterator<Item = StreamName>, ) -> Result<(), SpotWsError>
Subscribe to more streams.
Sourcepub async fn unsubscribe(
&self,
streams: impl IntoIterator<Item = StreamName>,
) -> Result<(), SpotWsError>
pub async fn unsubscribe( &self, streams: impl IntoIterator<Item = StreamName>, ) -> Result<(), SpotWsError>
Unsubscribe from streams. A stream not subscribed is ignored.