forked from cqerl/cqerl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcqerl_sup.erl
45 lines (34 loc) · 1.18 KB
/
cqerl_sup.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-module(cqerl_sup).
-behaviour(supervisor).
%% API
-export([start_link/0]).
%% Supervisor callbacks
-export([init/1]).
%% Helper macro for declaring children of supervisor
-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
%% ===================================================================
%% API functions
%% ===================================================================
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
%% ===================================================================
%% Supervisor callbacks
%% ===================================================================
init([]) ->
init(cqerl_app:mode());
init(pooler) ->
{ok, { {one_for_one, 5, 10}, [
?CHILD(cqerl, worker),
?CHILD(cqerl_cache, worker),
?CHILD(cqerl_batch_sup, supervisor),
?CHILD(cqerl_processor_sup, supervisor)
]}};
init(hash) ->
{ok, { {one_for_all, 5, 10}, [
?CHILD(cqerl_cache, worker),
?CHILD(cqerl_batch_sup, supervisor),
?CHILD(cqerl_processor_sup, supervisor),
?CHILD(cqerl_client_sup, supervisor),
?CHILD(cqerl_hash, worker),
?CHILD(cqerl_cluster, worker)
]}}.