RaftEx.Server.Cluster
(raft_ex v0.1.0)
View Source
Helpers for managing the cluster membership map inside a server state.
The cluster is a %{server_id => peer_state} map stored under :cluster in
the server state. This module keeps all mutation and query logic in one place
so that RaftEx.Server stays focused on the Raft protocol.
Summary
Functions
Return the highest index agreed upon by a quorum (majority).
Determine the membership role of id/uid within cluster.
Get a single peer's state, returning nil if not found.
Build an initial cluster map from a list or map of peer identifiers.
Return the peer ids excluding self.
Return all peers excluding self.
Reset all peer statuses to :normal (used on becoming follower).
Reset query_index to 0 for all peers (used on term change).
Update a peer by merging update into its current state.
Collect the match indexes of all voter peers plus the leader's own last written index.
Types
@type cluster() :: RaftEx.Types.cluster()
@type peer_state() :: RaftEx.Types.peer_state()
@type server_id() :: RaftEx.Types.server_id()
Functions
@spec agreed_commit([RaftEx.Types.index()]) :: RaftEx.Types.index()
Return the highest index agreed upon by a quorum (majority).
@spec get_membership( cluster(), server_id(), RaftEx.Types.uid(), RaftEx.Types.membership() ) :: RaftEx.Types.membership()
Determine the membership role of id/uid within cluster.
@spec get_peer(server_id(), cluster()) :: peer_state() | nil
Get a single peer's state, returning nil if not found.
Build an initial cluster map from a list or map of peer identifiers.
Return the peer ids excluding self.
Return all peers excluding self.
Reset all peer statuses to :normal (used on becoming follower).
Reset query_index to 0 for all peers (used on term change).
Update a peer by merging update into its current state.
@spec voter_match_indexes(server_id(), cluster(), RaftEx.Types.index()) :: [ RaftEx.Types.index() ]
Collect the match indexes of all voter peers plus the leader's own last written index.
Used to compute the new commit index.