squabble v0.1.0 Squabble.Server View Source
Implementation for the squabble server
Link to this section Summary
Functions
A new node joined the cluster, assert leadership
Check on the current term, and if it’s stuck
Check if the node has a majority of the votes
Check if a term is newer than the local state
Check if the node has voted in this term
Send back debug information from the squabble cluster
Reply to the leader check if the node is a leader
Check for a leader already in the cluster
A node went down, check if it was the leader
Set the winner as leader
Try to elect yourself as the leader
Vote for the leader
A vote came in from the cluster
Mark the current node as the new leader for the term
Get the winner subscription notices
Link to this section Types
Link to this section Functions
assert_leader(Squabble.State.t()) :: {:ok, Squabble.State.t()}
A new node joined the cluster, assert leadership
check_election_status(Squabble.State.t(), integer()) :: {:ok, Squabble.State.t()}
Check on the current term, and if it’s stuck
check_majority_votes(Squabble.State.t()) :: {:ok, :majority} | {:error, :not_enough}
Check if the node has a majority of the votes
check_term_newer(Squabble.State.t(), integer()) :: boolean()
Check if a term is newer than the local state
check_voted(Squabble.State.t()) :: {:ok, :not_voted} | {:error, :voted}
Check if the node has voted in this term
Send back debug information from the squabble cluster
leader_check(Squabble.State.t(), pid()) :: {:ok, Squabble.State.t()}
Reply to the leader check if the node is a leader
look_for_leader(Squabble.State.t()) :: {:ok, Squabble.State.t()}
Check for a leader already in the cluster
node_down(Squabble.State.t(), atom()) :: {:ok, Squabble.State.t()}
A node went down, check if it was the leader
Set the winner as leader
Try to elect yourself as the leader
Vote for the leader
A vote came in from the cluster
voted_leader(Squabble.State.t(), integer()) :: {:ok, Squabble.State.t()}
Mark the current node as the new leader for the term
Get the winner subscription notices