./ct_report/coverage/mongoose_wpool_sup.COVER.html

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(mongoose_wpool_sup).
17
18 -behaviour(supervisor).
19
20 %% API
21 -export([start_link/0]).
22
23 %% Supervisor callbacks
24 -export([init/1]).
25
26 -export([child_spec/1]).
27
28 -define(SERVER, ?MODULE).
29
30 %%%===================================================================
31 %%% API functions
32 %%%===================================================================
33
34 %%--------------------------------------------------------------------
35 %% @doc
36 %% Starts the supervisor
37 %%
38 %% @end
39 %%--------------------------------------------------------------------
40 -spec(start_link() ->
41 {ok, Pid :: pid()} | ignore | {error, Reason :: term()}).
42 start_link() ->
43 53 supervisor:start_link({local, ?SERVER}, ?MODULE, []).
44
45 %%%===================================================================
46 %%% Supervisor callbacks
47 %%%===================================================================
48
49 %%--------------------------------------------------------------------
50 %% @private
51 %% @doc
52 %% Whenever a supervisor is started using supervisor:start_link/[2, 3],
53 %% this function is called by the new process to find out about
54 %% restart strategy, maximum restart frequency and child
55 %% specifications.
56 %%
57 %% @end
58 %%--------------------------------------------------------------------
59 -spec init(Args :: term()) -> {ok, {#{strategy => one_for_one, intensity => 100, period => 5},
60 []}}.
61 init([]) ->
62 53 SupFlags = #{strategy => one_for_one,
63 intensity => 100,
64 period => 5},
65
66 53 {ok, {SupFlags, []}}.
67
68 %%%===================================================================
69 %%% Internal functions
70 %%%===================================================================
71 -spec child_spec(mongoose_wpool:pool_type()) ->
72 #{id := mongoose_wpool:proc_name(),
73 start := {mongoose_wpool_type_sup, start_link, [mongoose_wpool:pool_type()]},
74 restart => transient,
75 shutdown => infinity,
76 type => supervisor,
77 modules => [module()]}.
78 child_spec(Type) ->
79 112 #{id => mongoose_wpool_type_sup:name(Type),
80 start => {mongoose_wpool_type_sup, start_link, [Type]},
81 restart => transient,
82 shutdown => infinity,
83 type => supervisor,
84 modules => [mongoose_wpool_type_sup]
85 }.
86
Line Hits Source