RaftEx.Types
(raft_ex v0.1.0)
View Source
Shared type definitions and protocol message structs for the Raft implementation.
All Raft wire-protocol messages (RPCs, replies) are defined here as structs so they can be pattern-matched cleanly across the codebase.
Summary
Types
@type cluster() :: %{required(server_id()) => peer_state()}
@type index() :: non_neg_integer()
@type membership() :: :voter | :promotable | :non_voter | :unknown
@type peer_state() :: %{ optional(:voter_status) => voter_status(), optional(:machine_version) => non_neg_integer(), next_index: non_neg_integer(), match_index: non_neg_integer(), query_index: non_neg_integer(), commit_index_sent: non_neg_integer(), status: peer_status() }
@type peer_status() :: :normal | {:sending_snapshot, pid(), non_neg_integer()} | {:snapshot_backoff, non_neg_integer()} | :suspended | :disconnected
@type ra_state() ::
:leader
| :follower
| :candidate
| :pre_vote
| :await_condition
| :delete_and_terminate
| :terminating_leader
| :terminating_follower
| :recover
| :recovered
| :stop
| :receive_snapshot
@type term_num() :: non_neg_integer()
@type uid() :: binary()
@type voter_status() :: %{ optional(:membership) => membership(), optional(:uid) => uid(), optional(:target) => index() }