RaftRole

sealed interface RaftRole

The role a node holds at a given instant in Raft's state machine.

Only voters ever hold Leader, Follower, or Candidate. A node listed in ClusterConfig.learners is permanently Learner — it receives log replication from the leader but never votes and never stands for election. A learner can still call RaftNode.propose; the call forwards to the current leader like any non-leader role, and the committed entry replicates back.

Inheritors

Types

Link copied to clipboard
data object Candidate : RaftRole

This node has not heard from a leader within the election timeout and is soliciting votes to become the new leader.

Link copied to clipboard
data object Follower : RaftRole

This node is following the current leader and replicating its log.

Link copied to clipboard
data object Leader : RaftRole

This node won a quorum vote and is currently the elected leader.

Link copied to clipboard
data object Learner : RaftRole

This node is a non-voting learner: it receives replicated entries but never votes and never leads.