Module elector

This is the main API module.

Description

This is the main API module.

This module can be used to manually start new election or to check if the current node is the leader. The elector application has to be started before calling any of these functions. To start the elector add it to your supervision tree or start it manually.

When elector is started it will handle the elections automatically startup and when new node joins/leaves erlang the cluster. The elections are started automatically when new node joins the cluster or old one leaves. It is possible to start an election manually by calling elector:elect/0 or elect_sync/0.

See the README.md file for more information.

Function Index

elect/0Starts an election asynchronously.
elect_sync/0Starts an election synchronously.
get_leader/0Returns the current leader node's machine name.
is_leader/0Returns boolean true this node is the leader or false if not.

Function Details

elect/0

elect() -> {ok, election_started} | {error, quorum_size_not_met}

Starts an election asynchronously.

elect_sync/0

elect_sync() -> {ok, election_finished} | {error, term()}

Starts an election synchronously.

get_leader/0

get_leader() -> {ok, node()} | {error, leader_node_not_set}

Returns the current leader node's machine name.

is_leader/0

is_leader() -> {ok, boolean()} | {error, leader_node_not_set}

Returns boolean true this node is the leader or false if not.


Generated by EDoc