Skip to content

Commit 1fc7390

Browse files
Merge pull request #14434 from rabbitmq/mk-extract-dyn-shovel-supervisor
Shovel status: minor refactoring
2 parents ab71a39 + dee15f0 commit 1fc7390

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

deps/rabbitmq_shovel/src/rabbit_shovel_status.erl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
-module(rabbit_shovel_status).
99
-behaviour(gen_server).
1010

11+
-import(rabbit_shovel_util, [
12+
dynamic_shovel_supervisor_mod/0
13+
]).
14+
1115
-export([start_link/0]).
1216

1317
-export([report/3,
@@ -186,7 +190,8 @@ handle_cast({remove, Name}, State) ->
186190

187191
handle_info(check, State) ->
188192
try
189-
rabbit_shovel_dyn_worker_sup_sup:cleanup_specs()
193+
Mod = dynamic_shovel_supervisor_mod(),
194+
Mod:cleanup_specs()
190195
catch
191196
C:E ->
192197
?LOG_WARNING("Recurring shovel spec clean up failed with ~p:~p", [C, E])

deps/rabbitmq_shovel/src/rabbit_shovel_util.erl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
gen_unique_name/2,
1616
decl_fun/2]).
1717

18+
-export([
19+
dynamic_shovel_supervisor_mod/0
20+
]).
21+
1822
-include_lib("rabbit_common/include/rabbit_framing.hrl").
1923
-include_lib("rabbit_common/include/rabbit.hrl").
2024
-include_lib("kernel/include/logger.hrl").
@@ -23,6 +27,10 @@
2327
-define(ROUTING_HEADER, <<"x-shovelled">>).
2428
-define(TIMESTAMP_HEADER, <<"x-shovelled-timestamp">>).
2529

30+
-spec dynamic_shovel_supervisor_mod() -> module().
31+
dynamic_shovel_supervisor_mod() ->
32+
rabbit_shovel_dyn_worker_sup_sup.
33+
2634
update_headers(Prefix, Suffix, SrcURI, DestURI,
2735
Props = #'P_basic'{headers = Headers}) ->
2836
Table = Prefix ++ [{<<"src-uri">>, SrcURI},
@@ -92,9 +100,10 @@ restart_shovel(VHost, Name) ->
92100
not_found ->
93101
{error, not_found};
94102
_Obj ->
103+
Mod = dynamic_shovel_supervisor_mod(),
95104
?LOG_INFO("Shovel '~ts' in virtual host '~ts' will be restarted", [Name, VHost]),
96-
ok = rabbit_shovel_dyn_worker_sup_sup:stop_child({VHost, Name}),
97-
{ok, _} = rabbit_shovel_dyn_worker_sup_sup:start_link(),
105+
ok = Mod:stop_child({VHost, Name}),
106+
{ok, _} = Mod:start_link(),
98107
ok
99108
end.
100109

0 commit comments

Comments
 (0)