RaftEx.Server
(raft_ex v0.1.0)
View Source
Core Raft server logic: leader election, log replication, and state machine application.
This module is a pure-functional layer — it receives messages, computes the
next state and a list of effects, and returns them to the caller
(RaftEx.ServerProc), which owns the OTP process and actually executes the
effects.
Server state map keys
| Key | Description |
|---|---|
:cfg | RaftEx.Server.Config struct (immutable mostly) |
:leader_id | Current known leader, or nil |
:current_term | Raft term counter |
:cluster | %{server_id => peer_state} |
:cluster_change_permitted | Whether a cluster change may be appended now |
:cluster_index_term | {index, term} of the last cluster-change entry |
:voted_for | Server voted for in current term, or nil |
:membership | This server's own membership role |
:commit_index | Highest log index known to be committed |
:last_applied | Highest index applied to the state machine |
:persisted_last_applied | Value of :last_applied written to durable meta |
:log | RaftEx.Log state |
:machine_state | User state machine state |
:aux_state | Auxiliary state machine state |
:query_index | Monotonic index for consistent query tracking |
:queries_waiting_heartbeats | Queue of {query_index, query_ref} tuples |
:pending_consistent_queries | Queries queued awaiting cluster-change perm |
Summary
Functions
Build the initial server state from a configuration map.
Build AppendEntries RPCs for all peers (used on heartbeat / tick).
Persist last_applied to durable meta if it has advanced.
Replay committed log entries onto the state machine during startup.
Functions
@spec checkpoint(non_neg_integer(), term(), map()) :: {map(), list()}
@spec fetch_term(non_neg_integer(), map()) :: {non_neg_integer() | nil, map()}
Build the initial server state from a configuration map.
Build AppendEntries RPCs for all peers (used on heartbeat / tick).
Persist last_applied to durable meta if it has advanced.
@spec promote_checkpoint(non_neg_integer(), map()) :: {map(), list()}
Replay committed log entries onto the state machine during startup.