1%% This Source Code Form is subject to the terms of the Mozilla Public
2%% License, v. 2.0. If a copy of the MPL was not distributed with this
3%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
4%%
5%% Copyright (c) 2007-2021 VMware, Inc. or its affiliates.  All rights reserved.
6%%
7
8-module(rabbit_connection_helper_sup).
9
10%% Supervises auxiliary processes of AMQP 0-9-1 connections:
11%%
12%%  * Channel supervisor
13%%  * Heartbeat receiver
14%%  * Heartbeat sender
15%%  * Exclusive queue collector
16%%
17%% See also rabbit_heartbeat, rabbit_channel_sup_sup, rabbit_queue_collector.
18
19-behaviour(supervisor2).
20
21-export([start_link/0]).
22-export([start_channel_sup_sup/1,
23         start_queue_collector/2]).
24
25-export([init/1]).
26
27-include_lib("rabbit_common/include/rabbit.hrl").
28
29%%----------------------------------------------------------------------------
30
31-spec start_link() -> rabbit_types:ok_pid_or_error().
32
33start_link() ->
34    supervisor2:start_link(?MODULE, []).
35
36-spec start_channel_sup_sup(pid()) -> rabbit_types:ok_pid_or_error().
37
38start_channel_sup_sup(SupPid) ->
39    supervisor2:start_child(
40          SupPid,
41          {channel_sup_sup, {rabbit_channel_sup_sup, start_link, []},
42           intrinsic, infinity, supervisor, [rabbit_channel_sup_sup]}).
43
44-spec start_queue_collector(pid(), rabbit_types:proc_name()) ->
45          rabbit_types:ok_pid_or_error().
46
47start_queue_collector(SupPid, Identity) ->
48    supervisor2:start_child(
49      SupPid,
50      {collector, {rabbit_queue_collector, start_link, [Identity]},
51       intrinsic, ?WORKER_WAIT, worker, [rabbit_queue_collector]}).
52
53%%----------------------------------------------------------------------------
54
55init([]) ->
56    ?LG_PROCESS_TYPE(connection_helper_sup),
57    {ok, {{one_for_one, 10, 10}, []}}.
58