Skip to main content

ClusterEvents

Trait ClusterEvents 

Source
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§

Source

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.

Source

fn unsubscribe(&self, id: SubscriptionId) -> Result<(), ClusterError>

Remove a previously registered subscription. Idempotent.

Implementors§