Packages

Elects master node from Erlang/Elixir cluster that is agreed by all nodes.

Current section

Files

Jump to
elector src elector_sup.erl
Raw

src/elector_sup.erl

%%%-------------------------------------------------------------------
%% @doc elector top level supervisor.
%% @private
%% @end
%%%-------------------------------------------------------------------
-module(elector_sup).
%%--------------------------------------------------------------------
%% Behaviours
%%--------------------------------------------------------------------
-behaviour(supervisor).
%%--------------------------------------------------------------------
%% Exported API
%%--------------------------------------------------------------------
-export([start_link/0]).
-export([init/1]).
%%--------------------------------------------------------------------
%% Definitions
%%--------------------------------------------------------------------
-define(SERVER, ?MODULE).
%%--------------------------------------------------------------------
%% Exported functions
%%--------------------------------------------------------------------
%% @doc Starts the supervisor process.
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
%%--------------------------------------------------------------------
%% Callback functions
%%--------------------------------------------------------------------
init([]) ->
ElectionWorker = #{id => elector_worker, start => {elector_worker, start_link, []}},
SupFlags =
#{strategy => one_for_all,
intensity => 0,
period => 1},
ChildSpecs = [ElectionWorker],
{ok, {SupFlags, ChildSpecs}}.