libelection v0.1.2 Election.Elector

This module implements simple leader election using a provided strategy module

Options

  • strategy: A module to use to determine candidate nodes and pick one of them as the leader
  • first_election_in: How much time in milliseconds before trying to elect a leader for the first time. Defaults in 0.
  • polling_interval: How often to re-elect in milliseconds. Defaults to 1 second.

Link to this section Summary

Functions

Triggers an election

Returns the current leader node

Returns true only if the current node is the leader

Returns a list of all the nodes of the cluster including the current

Starts the an Election server with the given arguments

Link to this section Functions

Link to this function elect()
elect() :: :ok

Triggers an election

Link to this function elect(pid)
elect(pid()) :: :ok
Link to this function leader()
leader() :: node()

Returns the current leader node

Link to this function leader(pid)
leader(pid()) :: node()
Link to this function leader?()
leader?() :: boolean()

Returns true only if the current node is the leader

Link to this function leader?(pid)
leader?(pid()) :: boolean()
Link to this function list_nodes()
list_nodes() :: [node()]

Returns a list of all the nodes of the cluster including the current

Link to this function log(level, tag, fun)
Link to this function new_leader(map, state)
Link to this function start_link()
start_link() :: GenServer.on_start()

Starts the an Election server with the given arguments

Link to this function start_link(opts)
start_link(%{name: atom()} | map()) :: GenServer.on_start()