pub struct ClusterConfig {
pub voters: BTreeSet<NodeId>,
pub learners: BTreeSet<NodeId>,
}Expand description
The membership of the cluster: disjoint voter and learner sets.
A node appears in at most one set. Learners receive replication but never vote, never start elections, and never count toward any quorum.
Fields§
§voters: BTreeSet<NodeId>Nodes that vote and count toward quorums.
learners: BTreeSet<NodeId>Nodes that replicate without voting.
Implementations§
Source§impl ClusterConfig
impl ClusterConfig
Sourcepub fn new(
voters: impl IntoIterator<Item = NodeId>,
learners: impl IntoIterator<Item = NodeId>,
) -> Result<Self, ConfigError>
pub fn new( voters: impl IntoIterator<Item = NodeId>, learners: impl IntoIterator<Item = NodeId>, ) -> Result<Self, ConfigError>
Build a configuration from voter and learner id lists.
§Errors
Returns ConfigError::EmptyVoters when the voter list is empty
(a cluster may shrink to one voter, never to none) and
ConfigError::OverlappingMember when a node appears in both
voters and learners.
Source§impl ClusterConfig
impl ClusterConfig
Sourcepub fn apply_change(&self, change: ConfigChange) -> Result<Self, ProtocolError>
pub fn apply_change(&self, change: ConfigChange) -> Result<Self, ProtocolError>
The configuration produced by applying change to this one.
This checks the set-level rules only (who may be added,
promoted, or removed). The leader-side rules that need log
state (one uncommitted change, the NoOp gate, promotion
catch-up) are enforced by Node before it appends the entry.
§Errors
Returns the ProtocolError naming the rule the change breaks.