pub struct Cluster { /* private fields */ }Expand description
A distributed cluster of nodes.
Implementations§
Source§impl Cluster
impl Cluster
Sourcepub fn new(local_node: NodeInfo, config: ClusterConfig) -> Self
pub fn new(local_node: NodeInfo, config: ClusterConfig) -> Self
Create a new cluster.
Sourcepub fn config(&self) -> &ClusterConfig
pub fn config(&self) -> &ClusterConfig
Get the cluster configuration.
Sourcepub fn state(&self) -> ClusterState
pub fn state(&self) -> ClusterState
Get the current cluster state.
Sourcepub fn set_state(&self, state: ClusterState)
pub fn set_state(&self, state: ClusterState)
Set the cluster state.
Sourcepub fn local_node_id(&self) -> &NodeId
pub fn local_node_id(&self) -> &NodeId
Get the local node ID.
Sourcepub fn set_leader(&self, leader_id: Option<NodeId>)
pub fn set_leader(&self, leader_id: Option<NodeId>)
Set the leader ID.
Sourcepub fn remove_node(&self, node_id: &NodeId) -> Result<NodeInfo, ClusterError>
pub fn remove_node(&self, node_id: &NodeId) -> Result<NodeInfo, ClusterError>
Remove a node from the cluster.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get the number of nodes.
Sourcepub fn update_health(&self, health: NodeHealth)
pub fn update_health(&self, health: NodeHealth)
Update node health.
Sourcepub fn get_health(&self, node_id: &NodeId) -> Option<NodeHealth>
pub fn get_health(&self, node_id: &NodeId) -> Option<NodeHealth>
Get health for a node.
Sourcepub fn check_failures(&self) -> Vec<NodeId>
pub fn check_failures(&self) -> Vec<NodeId>
Check for failed nodes based on timeout.
Sourcepub fn has_quorum(&self) -> bool
pub fn has_quorum(&self) -> bool
Check if cluster has quorum.
Sourcepub fn stats(&self) -> ClusterStats
pub fn stats(&self) -> ClusterStats
Get cluster statistics.
Sourcepub fn voting_members(&self) -> Vec<NodeId>
pub fn voting_members(&self) -> Vec<NodeId>
Get nodes that can vote.
Sourcepub fn set_node_role(&self, node_id: &NodeId, role: NodeRole)
pub fn set_node_role(&self, node_id: &NodeId, role: NodeRole)
Update node role.
Auto Trait Implementations§
impl !Freeze for Cluster
impl RefUnwindSafe for Cluster
impl Send for Cluster
impl Sync for Cluster
impl Unpin for Cluster
impl UnsafeUnpin for Cluster
impl UnwindSafe for Cluster
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