Skip to content

Commit 1414a14

Browse files
Simplify rabbit_federation_exchange_link_sup_sup:adjust/1
1 parent a879138 commit 1414a14

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

deps/rabbitmq_federation/src/rabbit_federation_exchange_link_sup_sup.erl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ start_child(X) ->
9696

9797
child_exists(Name) ->
9898
Id = id(Name),
99-
%% older format, pre 3.13.0
99+
%% older format, pre-3.13.0
100100
OldId = old_id(Name),
101101
lists:any(fun ({ChildId, _, _, _}) ->
102102
ChildId =:= Id orelse ChildId =:= OldId
@@ -110,14 +110,9 @@ adjust({clear_upstream, VHost, UpstreamName}) ->
110110
],
111111
ok;
112112
adjust(Reason) ->
113-
_ = [case Id of
114-
{_, #exchange{} = X} ->
115-
rabbit_federation_link_sup:adjust(Pid, X, Reason);
116-
#exchange{} = X ->
117-
%% Old child id format, pre 3.13.0
118-
rabbit_federation_link_sup:adjust(Pid, X, Reason)
119-
end
120-
|| {Id, Pid, _, _} <- mirrored_supervisor:which_children(?SUPERVISOR)],
113+
_ = [rabbit_federation_link_sup:adjust(Pid, exchange_record_from_child_id(Id), Reason) ||
114+
{Id, Pid, _, _} <- mirrored_supervisor:which_children(?SUPERVISOR)
115+
],
121116
ok.
122117

123118
stop_child(X) ->
@@ -127,10 +122,10 @@ stop_child(X) ->
127122
{error, not_found} = Error ->
128123
case rabbit_khepri:is_enabled() of
129124
true ->
130-
%% Old id format is not supported by and cannot exist in Khepri
125+
%% Old id format is not supported by Khepri and cannot exist there
131126
Error;
132127
false ->
133-
%% try old format, pre 3.13.0
128+
%% try old format, pre-3.13.0
134129
stop_and_delete_child(old_id(X))
135130
end
136131
end,
@@ -171,8 +166,10 @@ old_id(X = #exchange{policy = Policy}) ->
171166
X1 = rabbit_exchange:immutable(X),
172167
X1#exchange{policy = Policy}.
173168

169+
%% New child id format, introduced in 3.13.0 for Khepri
174170
exchange_record_from_child_id({_, #exchange{} = XR}) ->
175171
XR;
172+
%% Old child id format, pre-3.13.0
176173
exchange_record_from_child_id(#exchange{} = XR) ->
177174
XR.
178175

0 commit comments

Comments
 (0)