./ct_report/coverage/mongoose_cets_discovery.COVER.html

1 -module(mongoose_cets_discovery).
2 -export([start_link/1]).
3 -export([supervisor_specs/0]).
4
5 -ignore_xref([start_link/1]).
6
7 start_link(DiscoOpts) ->
8 41 Res = cets_discovery:start_link(DiscoOpts),
9 %% Ensure metrics are added after the disco start
10 41 mongoose_metrics_probe_cets:start(),
11 41 Res.
12
13 -include("mongoose_logger.hrl").
14
15 supervisor_specs() ->
16 35 supervisor_specs(mongoose_config:get_opt([internal_databases, cets], disabled)).
17
18 supervisor_specs(disabled) ->
19
:-(
[];
20 supervisor_specs(#{backend := DiscoBackend, cluster_name := ClusterName} = Opts) ->
21 35 DiscoFile =
22 case {DiscoBackend, Opts} of
23 {file, #{node_list_file := NodeFile}} ->
24
:-(
NodeFile;
25 {file, _} ->
26
:-(
?LOG_CRITICAL(#{what => node_list_file_option_is_required,
27
:-(
text => <<"Specify internal_databases.cets.node_list_file option">>}),
28
:-(
error(node_list_file_option_is_required);
29 _ ->
30 35 undefined
31 end,
32 35 DiscoOpts = #{
33 backend_module => disco_backend_to_module(DiscoBackend),
34 cluster_name => atom_to_binary(ClusterName),
35 node_name_to_insert => atom_to_binary(node(), latin1),
36 node_ip_binary => get_node_ip_binary(),
37 name => mongoose_cets_discovery, disco_file => DiscoFile},
38 35 CetsDisco = #{
39 id => cets_discovery,
40 start => {?MODULE, start_link, [DiscoOpts]},
41 restart => permanent,
42 type => worker,
43 shutdown => infinity,
44 modules => [cets_discovery]},
45 35 [CetsDisco].
46
47 35 disco_backend_to_module(rdbms) -> mongoose_cets_discovery_rdbms;
48
:-(
disco_backend_to_module(file) -> cets_discovery_file.
49
50 get_node_ip_binary() ->
51 35 list_to_binary(os:getenv("MIM_NODE_IP", "")).
Line Hits Source