Packages

An Eventual Leader Election Library for Erlang

Current section

Files

Jump to
evel src evel_sup.erl
Raw

src/evel_sup.erl

%% Copyright (c) 2016 Takeru Ohta <phjgt308@gmail.com>
%%
%% This software is released under the MIT License.
%% See the LICENSE file in the project root for full license information.
%%
%% @doc Root Supervisor
%% @private
%% @end
-module(evel_sup).
-behaviour(supervisor).
%%----------------------------------------------------------------------------------------------------------------------
%% Exported API
%%----------------------------------------------------------------------------------------------------------------------
-export([start_link/0]).
%%----------------------------------------------------------------------------------------------------------------------
%% 'supervisor' Callback API
%%----------------------------------------------------------------------------------------------------------------------
-export([init/1]).
%%----------------------------------------------------------------------------------------------------------------------
%% Exported Functions
%%----------------------------------------------------------------------------------------------------------------------
%% @doc Starts the supervisor
-spec start_link() -> {ok, pid()} | {error, Reason::term()}.
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
%%----------------------------------------------------------------------------------------------------------------------
%% 'supervisor' Callback Functions
%%----------------------------------------------------------------------------------------------------------------------
%% @private
init([]) ->
Children =
[
#{id => commission, start => {evel_commission, start_link, []}},
#{id => voter, start => {evel_voter, start_link, []}},
#{id => people, start => {evel_people, start_link, []}},
#{id => agent_sup, start => {evel_agent_sup, start_link, []}, type => supervisor}
],
{ok, {#{strategy => rest_for_one}, Children}}.