pub enum ConfigState {
Stable(ClusterConfig),
Joint {
old: ClusterConfig,
new: ClusterConfig,
},
}Expand description
The state of cluster configuration during membership changes.
Implements the Raft joint consensus protocol (Section 6):
Stable: Normal operation with a single configurationJoint: Transitional state requiring majority from BOTH old and new configs
Variants§
Stable(ClusterConfig)
Normal operation with a single configuration
Joint
Joint consensus: decisions require majority of both old and new configs
Fields
§
old: ClusterConfigThe old (current) configuration
§
new: ClusterConfigThe new (target) configuration
Implementations§
Source§impl ConfigState
impl ConfigState
Sourcepub fn new_stable(members: Vec<(NodeId, String)>) -> Self
pub fn new_stable(members: Vec<(NodeId, String)>) -> Self
Create a new stable config state
Sourcepub fn all_member_ids(&self) -> HashSet<NodeId>
pub fn all_member_ids(&self) -> HashSet<NodeId>
Get all unique member node IDs across both configs (if joint)
Sourcepub fn has_quorum(&self, responding_nodes: &HashSet<NodeId>) -> bool
pub fn has_quorum(&self, responding_nodes: &HashSet<NodeId>) -> bool
Check if a given set of responding nodes forms a quorum.
During joint consensus, a quorum requires majority in BOTH the old and new configurations independently.
Sourcepub fn stable_config(&self) -> Option<&ClusterConfig>
pub fn stable_config(&self) -> Option<&ClusterConfig>
Get the stable config (only valid if not in joint state)
Sourcepub fn all_members(&self) -> Vec<(NodeId, String)>
pub fn all_members(&self) -> Vec<(NodeId, String)>
Get all members as (node_id, address) pairs
Trait Implementations§
Source§impl Clone for ConfigState
impl Clone for ConfigState
Source§fn clone(&self) -> ConfigState
fn clone(&self) -> ConfigState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConfigState
impl Debug for ConfigState
Source§impl PartialEq for ConfigState
impl PartialEq for ConfigState
impl Eq for ConfigState
impl StructuralPartialEq for ConfigState
Auto Trait Implementations§
impl Freeze for ConfigState
impl RefUnwindSafe for ConfigState
impl Send for ConfigState
impl Sync for ConfigState
impl Unpin for ConfigState
impl UnsafeUnpin for ConfigState
impl UnwindSafe for ConfigState
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