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.

Data Types

leader_node()

leader_node() = node() | undefined

Function Index

clear_leader/0Clears the leader node and sets it to undefined.
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

clear_leader/0

clear_leader() -> {ok, leader_cleared}

Clears the leader node and sets it to undefined.

elect/0

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

Starts an election asynchronously.

elect_sync/0

elect_sync() -> {ok, leader_node()} | {error, quorum_size_not_met} | {error, election_commission_not_up}

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