readIndex

open suspend fun readIndex(): Long

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.

Concurrent calls in the same heartbeat window share one round. A single-voter cluster returns immediately. A freshly-elected leader suspends until its current-term no-op commits before returning. Because the state machine is external (driven by committed), the caller must wait until it has applied through the returned index — see awaitRead.

The returned index is a commitIndex, so it counts entries whose contents are withheld from committed — the §5.4.2 no-op this call may have just waited for, and any §6 config entry. It is reachable anyway: each such index arrives as a Committed.Internal marker, so a consumer that folds the whole stream (not just Committed.Entry) advances past them. A consumer that folds only application entries will sit below the returned index after an election or a membership change until unrelated traffic commits past the gap — a gate written that way refuses a legitimate act, and a wait written that way blocks (#1718).

Throws

if this node is not the leader (including learners).

if leadership is lost before the round confirms.