pub struct ClusterCoordinator { /* private fields */ }Expand description
Cluster coordinator for managing RAFT nodes
Implementations§
Source§impl ClusterCoordinator
impl ClusterCoordinator
Sourcepub fn new(config: ClusterConfig) -> Self
pub fn new(config: ClusterConfig) -> Self
Create a new cluster coordinator
Sourcepub async fn set_failover_callback<F>(&self, callback: F)
pub async fn set_failover_callback<F>(&self, callback: F)
Set a callback to be invoked when leader failover is triggered
Sourcepub async fn add_node(&self, node_id: NodeId, address: SocketAddr) -> Result<()>
pub async fn add_node(&self, node_id: NodeId, address: SocketAddr) -> Result<()>
Add a node to the cluster
Sourcepub async fn remove_node(&self, node_id: NodeId) -> Result<()>
pub async fn remove_node(&self, node_id: NodeId) -> Result<()>
Remove a node from the cluster
Sourcepub async fn update_node_state(
&self,
node_id: NodeId,
state: NodeState,
) -> Result<()>
pub async fn update_node_state( &self, node_id: NodeId, state: NodeState, ) -> Result<()>
Update node state
Sourcepub async fn start_health_monitoring(&self)
pub async fn start_health_monitoring(&self)
Start health monitoring background task
Sourcepub async fn trigger_failover(&self) -> Result<()>
pub async fn trigger_failover(&self) -> Result<()>
Manually trigger failover (for testing or manual intervention)
Sourcepub async fn should_trigger_reelection(&self) -> bool
pub async fn should_trigger_reelection(&self) -> bool
Check if automatic re-election should be triggered
Sourcepub fn get_election_candidates(&self) -> Vec<NodeId>
pub fn get_election_candidates(&self) -> Vec<NodeId>
Get healthy nodes that can participate in election
Sourcepub fn cluster_size(&self) -> usize
pub fn cluster_size(&self) -> usize
Get current cluster size
Sourcepub fn healthy_nodes(&self) -> usize
pub fn healthy_nodes(&self) -> usize
Get number of healthy nodes
Sourcepub fn has_quorum(&self) -> bool
pub fn has_quorum(&self) -> bool
Check if cluster has quorum
Sourcepub async fn get_leader(&self) -> Option<NodeId>
pub async fn get_leader(&self) -> Option<NodeId>
Get current leader
Sourcepub fn get_node_ids(&self) -> Vec<NodeId>
pub fn get_node_ids(&self) -> Vec<NodeId>
Get all node IDs
Sourcepub fn get_node_info(&self, node_id: NodeId) -> Option<NodeInfo>
pub fn get_node_info(&self, node_id: NodeId) -> Option<NodeInfo>
Get node info
Sourcepub fn get_cluster_stats(&self) -> ClusterStats
pub fn get_cluster_stats(&self) -> ClusterStats
Get cluster statistics
Auto Trait Implementations§
impl Freeze for ClusterCoordinator
impl !RefUnwindSafe for ClusterCoordinator
impl Send for ClusterCoordinator
impl Sync for ClusterCoordinator
impl Unpin for ClusterCoordinator
impl !UnwindSafe for ClusterCoordinator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more