pub enum Role {
Follower,
Candidate,
Leader,
}Expand description
The role a node currently plays in the consensus protocol.
A node is always in exactly one role. It starts as a Follower, may
become a Candidate when it stops hearing from a leader, and becomes a
Leader if it wins an election.
§Examples
use raft_io::{RaftConfig, RaftNode, Role};
let node = RaftNode::new(RaftConfig::single(1));
assert_eq!(node.role(), Role::Follower);Variants§
Follower
Passive replica: serves the leader and votes in elections.
Candidate
Standing for election in the current term, collecting votes.
Leader
Won the election for the current term; drives replication.
Trait Implementations§
impl Copy for Role
impl Eq for Role
impl StructuralPartialEq for Role
Auto Trait Implementations§
impl Freeze for Role
impl RefUnwindSafe for Role
impl Send for Role
impl Sync for Role
impl Unpin for Role
impl UnsafeUnpin for Role
impl UnwindSafe for Role
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