RaftNode
The runtime interface for a single Raft cluster member.
Obtain an instance via CoroutineScope.raftNode. The node starts running immediately and remains active until close is called or the owning CoroutineScope is cancelled.
Testing multi-node clusters? Use MultiNodeRaftSim from :kuilt-raft-test — it handles the ceremony (in-process network, per-node seeded RaftConfig.random for symmetry-breaking, child scopes on backgroundScope, bounded await helpers) so you don't hand-roll it per test.
Properties
The index of the highest log entry known to be committed by a quorum.
The lastIncludedIndex of the most recent compaction, or 0 if nothing has been compacted.
The current RaftRole of this node — RaftRole.Leader, RaftRole.Follower, RaftRole.Candidate, or RaftRole.Learner.
The outbound snapshot channel. The consumer publishes its latest durable state-machine snapshot here on its own clock (snapshots.value = Snapshot(appliedIndex, bytes)); raft samples it on its own clock to compact the log prefix and to serve a lagging follower. Conflated — only the newest snapshot matters. Leaving it null disables compaction (the pre-compaction behavior).
Hot Flow of RaftTraceEvents — one event per engine state transition.
Functions
Suspends until this node is observed in the RaftRole.Leader role.
Linearizable read barrier: confirms the read index via RaftNode.readIndex, then suspends until applied reaches it, returning that index. applied is the caller's own monotonic applied-index flow, advanced as it consumes RaftNode.committed.
Aborts an in-flight transferLeadership and re-enables proposal acceptance.
Proposes command for replication and suspends until a quorum commits it.
Confirms this leader still holds a voter-quorum at its current term, then returns a read index: a commit index ri such that any state machine that has applied through ri reflects every write committed before this call. The read is linearizable once the caller's apply loop reaches ri. The leader does not write to the log.
Initiates a graceful leadership transfer to target per Raft §3.10, and suspends until the transfer either completes (target wins an election) or fails.