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

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

Link to this function assert_leader(state) View Source
assert_leader(Squabble.State.t()) :: {:ok, Squabble.State.t()}

A new node joined the cluster, assert leadership

Link to this function check_election_status(state, term) View Source
check_election_status(Squabble.State.t(), integer()) ::
  {:ok, Squabble.State.t()}

Check on the current term, and if it’s stuck

Link to this function check_majority_votes(state) View Source
check_majority_votes(Squabble.State.t()) ::
  {:ok, :majority} | {:error, :not_enough}

Check if the node has a majority of the votes

Link to this function check_term_newer(state, term) View Source
check_term_newer(Squabble.State.t(), integer()) :: boolean()

Check if a term is newer than the local state

Link to this function check_voted(state) View Source
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

Link to this function leader_check(state, pid) View Source
leader_check(Squabble.State.t(), pid()) :: {:ok, Squabble.State.t()}

Reply to the leader check if the node is a leader

Link to this function look_for_leader(state) View Source
look_for_leader(Squabble.State.t()) :: {:ok, Squabble.State.t()}

Check for a leader already in the cluster

Link to this function node_down(state, node) View Source
node_down(Squabble.State.t(), atom()) :: {:ok, Squabble.State.t()}

A node went down, check if it was the leader

Link to this function set_leader(state, leader_pid, leader_node, term) View Source

Set the winner as leader

Link to this function start_election(state, term) View Source

Try to elect yourself as the leader

Link to this function vote_leader(state, pid, term) View Source

Vote for the leader

Link to this function vote_received(state, pid, term) View Source

A vote came in from the cluster

Link to this function voted_leader(state, term) View Source
voted_leader(Squabble.State.t(), integer()) :: {:ok, Squabble.State.t()}

Mark the current node as the new leader for the term

Link to this function winner_subscriptions(state) View Source

Get the winner subscription notices