1 |
|
%%============================================================================== |
2 |
|
%% Copyright 2018 Erlang Solutions Ltd. |
3 |
|
%% |
4 |
|
%% Licensed under the Apache License, Version 2.0 (the "License"); |
5 |
|
%% you may not use this file except in compliance with the License. |
6 |
|
%% You may obtain a copy of the License at |
7 |
|
%% |
8 |
|
%% http://www.apache.org/licenses/LICENSE-2.0 |
9 |
|
%% |
10 |
|
%% Unless required by applicable law or agreed to in writing, software |
11 |
|
%% distributed under the License is distributed on an "AS IS" BASIS, |
12 |
|
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 |
|
%% See the License for the specific language governing permissions and |
14 |
|
%% limitations under the License. |
15 |
|
%%============================================================================== |
16 |
|
-module(ejabberd_shaper_sup). |
17 |
|
|
18 |
|
-behaviour(supervisor). |
19 |
|
|
20 |
|
%% API |
21 |
|
-export([start_link/0]). |
22 |
|
|
23 |
|
%% Supervisor callbacks |
24 |
|
-export([init/1]). |
25 |
|
|
26 |
|
-ignore_xref([start_link/0]). |
27 |
|
|
28 |
|
%% -export([child_spec/1]). |
29 |
|
|
30 |
|
-define(SERVER, ?MODULE). |
31 |
|
|
32 |
|
%%%=================================================================== |
33 |
|
%%% API functions |
34 |
|
%%%=================================================================== |
35 |
|
|
36 |
|
%%-------------------------------------------------------------------- |
37 |
|
%% @doc |
38 |
|
%% Starts the supervisor |
39 |
|
%% |
40 |
|
%% @end |
41 |
|
%%-------------------------------------------------------------------- |
42 |
|
-spec(start_link() -> |
43 |
|
{ok, Pid :: pid()} | ignore | {error, Reason :: term()}). |
44 |
|
start_link() -> |
45 |
76 |
supervisor:start_link({local, ?SERVER}, ?MODULE, []). |
46 |
|
|
47 |
|
%%%=================================================================== |
48 |
|
%%% Supervisor callbacks |
49 |
|
%%%=================================================================== |
50 |
|
|
51 |
|
%%-------------------------------------------------------------------- |
52 |
|
%% @private |
53 |
|
%% @doc |
54 |
|
%% Whenever a supervisor is started using supervisor:start_link/[2, 3], |
55 |
|
%% this function is called by the new process to find out about |
56 |
|
%% restart strategy, maximum restart frequency and child |
57 |
|
%% specifications. |
58 |
|
%% |
59 |
|
%% @end |
60 |
|
%%-------------------------------------------------------------------- |
61 |
|
-spec init([]) -> {ok, {#{strategy => one_for_one, intensity => 100, period => 5}, |
62 |
|
[supervisor:child_spec()]}}. |
63 |
|
init([]) -> |
64 |
76 |
SupFlags = #{strategy => one_for_one, |
65 |
|
intensity => 100, |
66 |
|
period => 5}, |
67 |
76 |
Shapers = shaper_srv:child_specs(), |
68 |
76 |
{ok, { SupFlags, Shapers }}. |