pub trait ClusterEvents:
Send
+ Sync
+ 'static {
// Required methods
fn subscribe(
&self,
on_event: Box<dyn Fn(ClusterEvent) + Send + Sync>,
) -> Result<SubscriptionId, ClusterError>;
fn unsubscribe(&self, id: SubscriptionId) -> Result<(), ClusterError>;
}Expand description
Subscription to cluster membership events.
Required Methods§
Sourcefn subscribe(
&self,
on_event: Box<dyn Fn(ClusterEvent) + Send + Sync>,
) -> Result<SubscriptionId, ClusterError>
fn subscribe( &self, on_event: Box<dyn Fn(ClusterEvent) + Send + Sync>, ) -> Result<SubscriptionId, ClusterError>
Subscribe to cluster membership changes. The callback is invoked for
each ClusterEvent (NodeJoined, NodeLeft, NodeRejected).
Returns a SubscriptionId that can be used to cancel the
subscription.
Sourcefn unsubscribe(&self, id: SubscriptionId) -> Result<(), ClusterError>
fn unsubscribe(&self, id: SubscriptionId) -> Result<(), ClusterError>
Remove a previously registered subscription. Idempotent.