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 delta.
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§
Sourceasync fn start(&mut self) -> Result<(), DiscoveryError>
async fn start(&mut self) -> Result<(), DiscoveryError>
Start the discovery service.
This spawns background tasks for heartbeating and failure detection.
Sourceasync fn peers(&self) -> Result<Vec<NodeInfo>, DiscoveryError>
async fn peers(&self) -> Result<Vec<NodeInfo>, DiscoveryError>
Get the current set of known peers (excluding self).
Sourceasync fn announce(&self, info: NodeInfo) -> Result<(), DiscoveryError>
async fn announce(&self, info: NodeInfo) -> Result<(), DiscoveryError>
Announce this node’s updated information to the cluster.
Sourcefn membership_watch(&self) -> Receiver<Vec<NodeInfo>>
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.
Sourceasync fn stop(&mut self) -> Result<(), DiscoveryError>
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", so this trait is not object safe.