@@ -26,9 +26,18 @@ start_link() ->
2626init ([Configurations ]) ->
2727 OpMode = rabbit_shovel_operating_mode :operating_mode (),
2828 ? LOG_DEBUG (" Shovel: operating mode set to ~ts " , [OpMode ]),
29- StaticShovelSpecs = make_child_specs ( OpMode , Configurations ),
29+
3030 Len = dict :size (Configurations ),
31- ChildSpecs = [
31+ SupTreeSpecs = supervisor_tree_child_specs (OpMode ),
32+ StaticShovelSpecs = static_shovel_child_specs (OpMode , Configurations ),
33+
34+ ChildSpecs = SupTreeSpecs ++ StaticShovelSpecs ,
35+ Opts = #{strategy => one_for_one , intensity => 2 * Len , period => 2 },
36+ {ok , {Opts , ChildSpecs }}.
37+
38+
39+ supervisor_tree_child_specs (standard ) ->
40+ [
3241 #{
3342 id => rabbit_shovel_status ,
3443 start => {rabbit_shovel_status , start_link , []},
@@ -45,13 +54,12 @@ init([Configurations]) ->
4554 type => supervisor ,
4655 modules => [rabbit_shovel_dyn_worker_sup_sup ]
4756 }
48- | StaticShovelSpecs
49- ],
50- Opts = #{strategy => one_for_one , intensity => 2 * Len , period => 2 },
51- {ok , {Opts , ChildSpecs }}.
57+ ];
58+ supervisor_tree_child_specs (_NonStandardOpMode ) ->
59+ [].
5260
5361
54- make_child_specs (standard , Configurations ) ->
62+ static_shovel_child_specs (standard , Configurations ) ->
5563 dict :fold (
5664 fun (ShovelName , ShovelConfig , Acc ) ->
5765 [
@@ -66,7 +74,7 @@ make_child_specs(standard, Configurations) ->
6674 | Acc
6775 ]
6876 end , [], Configurations );
69- make_child_specs (_NonStandardOpMode , _Configurations ) ->
77+ static_shovel_child_specs (_NonStandardOpMode , _Configurations ) ->
7078 % % when operating in a non-standard mode, do not start any shovels
7179 [].
7280
0 commit comments