Skip to main content

Discovery

Trait Discovery 

Source
pub trait Discovery:
    Send
    + Sync
    + 'static {
    // Required methods
    async fn start(&mut self) -> Result<(), DiscoveryError>;
    async fn peers(&self) -> Result<Vec<NodeInfo>, DiscoveryError>;
    async fn announce(&self, info: NodeInfo) -> Result<(), DiscoveryError>;
    fn membership_watch(&self) -> Receiver<Vec<NodeInfo>>;
    async fn stop(&mut self) -> Result<(), DiscoveryError>;
}
Expand description

Trait for node discovery in a cluster.

Implementations provide the mechanism by which nodes find and track each other. The trait is async and designed for long-running background tasks.

Required Methods§

Source

async fn start(&mut self) -> Result<(), DiscoveryError>

Start the discovery service.

This spawns background tasks for heartbeating and failure detection.

Source

async fn peers(&self) -> Result<Vec<NodeInfo>, DiscoveryError>

Get the current set of known peers (excluding self).

Source

async fn announce(&self, info: NodeInfo) -> Result<(), DiscoveryError>

Announce this node’s updated information to the cluster.

Source

fn membership_watch(&self) -> Receiver<Vec<NodeInfo>>

Subscribe to membership change events.

Returns a watch receiver that is updated whenever the membership changes. The value is the list of all known peers.

Source

async fn stop(&mut self) -> Result<(), DiscoveryError>

Gracefully stop the discovery service.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§