elector_strategy_behaviour behaviour (elector v0.3.2)

View Source

Defines the base behaviour for election strategies.

Summary

Functions

Returns a list of nodes that are eligible to become the leader.

Starts the election process by triggering the strategy modules elect() function. The election implementation should only contain the logic for selecting the leader node and returning the leader node name. The elect/0 function is triggered on all nodes automatically by the elector application. This means the strategy implementation does not have to worry about starting the election on all nodes.

Types

candidate_nodes/0

-type candidate_nodes() :: [node()].

leader/0

-type leader() :: node().

Callbacks

elect/1

-callback elect(CandidateNodes :: candidate_nodes()) -> Leader :: leader().

Functions

candidate_nodes()

-spec candidate_nodes() -> CandidateNodes :: candidate_nodes().

Returns a list of nodes that are eligible to become the leader.

elect()

-spec elect() -> Leader :: leader().

Starts the election process by triggering the strategy modules elect() function. The election implementation should only contain the logic for selecting the leader node and returning the leader node name. The elect/0 function is triggered on all nodes automatically by the elector application. This means the strategy implementation does not have to worry about starting the election on all nodes.