Skip to content

Commit

Permalink
Adapt federation and shovel to changes in exchange behaviour and mirr…
Browse files Browse the repository at this point in the history
…ored_supervisor
  • Loading branch information
dcorbacho committed Jan 13, 2023
1 parent d3ad3e5 commit eca6557
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 17 deletions.
14 changes: 3 additions & 11 deletions deps/rabbitmq_federation/src/rabbit_federation_exchange.erl
Expand Up @@ -21,7 +21,7 @@
-behaviour(rabbit_exchange_decorator).

-export([description/0, serialise_events/1]).
-export([create/2, delete/3, policy_changed/2,
-export([create/2, delete/2, policy_changed/2,
add_binding/3, remove_bindings/3, route/2, active_for/1]).

%%----------------------------------------------------------------------------
Expand All @@ -31,31 +31,23 @@ description() ->

serialise_events(X) -> federate(X).

create(transaction, _X) ->
ok;
create(none, X) ->
create(_Serial, X) ->
maybe_start(X).

delete(transaction, _X, _Bs) ->
ok;
delete(none, X, _Bs) ->
delete(_Serial, X) ->
maybe_stop(X).

policy_changed(OldX, NewX) ->
maybe_stop(OldX),
maybe_start(NewX).

add_binding(transaction, _X, _B) ->
ok;
add_binding(Serial, X = #exchange{name = XName}, B) ->
case federate(X) of
true -> rabbit_federation_exchange_link:add_binding(Serial, XName, B),
ok;
false -> ok
end.

remove_bindings(transaction, _X, _Bs) ->
ok;
remove_bindings(Serial, X = #exchange{name = XName}, Bs) ->
case federate(X) of
true -> rabbit_federation_exchange_link:remove_bindings(Serial, XName, Bs),
Expand Down
Expand Up @@ -27,7 +27,6 @@ start_link() ->
%% The scope is stopped in stop/1.
rabbit_federation_pg:start_scope(),
mirrored_supervisor:start_link({local, ?SUPERVISOR}, ?SUPERVISOR,
fun rabbit_misc:execute_mnesia_transaction/1,
?MODULE, []).

%% Note that the next supervisor down, rabbit_federation_link_sup, is common
Expand Down
Expand Up @@ -28,7 +28,6 @@ start_link() ->
%% The scope is stopped in stop/1.
rabbit_federation_pg:start_scope(),
mirrored_supervisor:start_link({local, ?SUPERVISOR}, ?SUPERVISOR,
fun rabbit_misc:execute_mnesia_transaction/1,
?MODULE, []).

%% Note that the next supervisor down, rabbit_federation_link_sup, is common
Expand Down
Expand Up @@ -23,7 +23,7 @@

-export([description/0, serialise_events/0, route/2]).
-export([validate/1, validate_binding/2,
create/2, delete/3, policy_changed/2,
create/2, delete/2, policy_changed/2,
add_binding/3, remove_bindings/3, assert_args_equivalence/2]).
-export([info/1, info/2]).

Expand Down Expand Up @@ -64,7 +64,7 @@ validate(#exchange{arguments = Args}) ->

validate_binding(_X, _B) -> ok.
create(_Tx, _X) -> ok.
delete(_Tx, _X, _Bs) -> ok.
delete(_Tx, _X) -> ok.
policy_changed(_X1, _X2) -> ok.
add_binding(_Tx, _X, _B) -> ok.
remove_bindings(_Tx, _X, _Bs) -> ok.
Expand Down
Expand Up @@ -20,7 +20,7 @@
start_link() ->
Pid = case mirrored_supervisor:start_link(
{local, ?SUPERVISOR}, ?SUPERVISOR,
fun rabbit_misc:execute_mnesia_transaction/1, ?MODULE, []) of
?MODULE, []) of
{ok, Pid0} -> Pid0;
{error, {already_started, Pid0}} -> Pid0
end,
Expand Down
1 change: 0 additions & 1 deletion deps/rabbitmq_shovel/src/rabbit_shovel_worker_sup.erl
Expand Up @@ -15,7 +15,6 @@

start_link(ShovelName, ShovelConfig) ->
mirrored_supervisor:start_link({local, ShovelName}, ShovelName,
fun rabbit_misc:execute_mnesia_transaction/1,
?MODULE, [ShovelName, ShovelConfig]).

init([Name, Config]) ->
Expand Down

0 comments on commit eca6557

Please sign in to comment.