Currently in testing: the GitHub code will be opened once complete.

RPC Types

The tag in a frame decides the RPC type. Every payload is an openraft type serialized with postcard.

tagNameRequest payloadResponse payloadRole
1VoteVoteRequestVoteResponseLeader election — a candidate asks other nodes for their vote
2AppendEntriesAppendEntriesRequestAppendEntriesResponseLog replication + heartbeat — the leader propagates replicated commands to followers
3FullSnapshota (Vote, SnapshotMeta, snapshot_bytes) tupleSnapshotResponseSends the entire snapshot to a node that's fallen behind
  • Vote — when the leader dies, a node whose heartbeat has stopped becomes a candidate and requests votes; the node that wins a majority becomes the new leader.
  • AppendEntries — the leader carries lock commands to commit as log entries. An AppendEntries with no entries is the heartbeat — there's no separate heartbeat message.
  • FullSnapshot — sends the entire current state to a node too far behind to catch up via the log (or one that just joined). Sent whole, in a single frame, with no streaming.

Flow — When the Leader Dies

Node A
Node B
Node C
detects the leader's heartbeat is gone → becomes a candidate
Vote · requesting a vote
Vote · requesting a vote
yes
majority including itself → new leader
AppendEntries (no entries = heartbeat)
AppendEntries (no entries = heartbeat)
consensus RPC (Raft)

The moment the newly elected leader's first heartbeat arrives, the cluster is back to normal service — the total gap is usually 0.5-1 second. See Replicated Commands for the AppendEntries (log replication) flow during normal operation.

Terminology

  • log replication — the leader turns its decided commands into an ordered log and has followers record it verbatim. Applying the same log in the same order brings every node to the same state.
  • heartbeat — a periodic "I'm alive" signal. When it stops, followers conclude the leader has died and start an election.