Skip to content

Commit 1749a9e

Browse files
committed
rabbit_channel: Pass rabbit_binding function to binding_action/10
This refactor is pulled from <https://redirect.github.com/rabbitmq/rabbitmq-server/pull/10559>, necessary for the error message when adding/deleting a binding fails.
1 parent 3c74225 commit 1749a9e

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

deps/rabbit/src/rabbit_channel.erl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ queue_down_consumer_action(CTag, CMap) ->
18761876
_ -> {recover, ConsumeSpec}
18771877
end.
18781878

1879-
binding_action(Fun, SourceNameBin0, DestinationType, DestinationNameBin0,
1879+
binding_action(Action, SourceNameBin0, DestinationType, DestinationNameBin0,
18801880
RoutingKey, Arguments, VHostPath, ConnPid, AuthzContext,
18811881
#user{username = Username} = User) ->
18821882
ExchangeNameBin = strip_cr_lf(SourceNameBin0),
@@ -1892,10 +1892,10 @@ binding_action(Fun, SourceNameBin0, DestinationType, DestinationNameBin0,
18921892
{ok, Exchange} ->
18931893
check_read_permitted_on_topic(Exchange, User, RoutingKey, AuthzContext)
18941894
end,
1895-
case Fun(#binding{source = ExchangeName,
1896-
destination = DestinationName,
1897-
key = RoutingKey,
1898-
args = Arguments},
1895+
case rabbit_binding:Action(#binding{source = ExchangeName,
1896+
destination = DestinationName,
1897+
key = RoutingKey,
1898+
args = Arguments},
18991899
fun (_X, Q) when ?is_amqqueue(Q) ->
19001900
try rabbit_amqqueue:check_exclusive_access(Q, ConnPid)
19011901
catch exit:Reason -> {error, Reason}
@@ -2384,15 +2384,15 @@ i(Item, _) ->
23842384
throw({bad_argument, Item}).
23852385

23862386
pending_raft_commands(QStates) ->
2387-
Fun = fun(_, V, Acc) ->
2387+
Action = fun(_, V, Acc) ->
23882388
case rabbit_queue_type:state_info(V) of
23892389
#{pending_raft_commands := P} ->
23902390
Acc + P;
23912391
_ ->
23922392
Acc
23932393
end
23942394
end,
2395-
rabbit_queue_type:fold_state(Fun, 0, QStates).
2395+
rabbit_queue_type:fold_state(Action, 0, QStates).
23962396

23972397
name(#ch{cfg = #conf{conn_name = ConnName, channel = Channel}}) ->
23982398
list_to_binary(rabbit_misc:format("~ts (~tp)", [ConnName, Channel])).
@@ -2444,31 +2444,31 @@ handle_method(#'exchange.bind'{destination = DestinationNameBin,
24442444
routing_key = RoutingKey,
24452445
arguments = Arguments},
24462446
ConnPid, AuthzContext, _CollectorId, VHostPath, User) ->
2447-
binding_action(fun rabbit_binding:add/3,
2447+
binding_action(add,
24482448
SourceNameBin, exchange, DestinationNameBin,
24492449
RoutingKey, Arguments, VHostPath, ConnPid, AuthzContext, User);
24502450
handle_method(#'exchange.unbind'{destination = DestinationNameBin,
24512451
source = SourceNameBin,
24522452
routing_key = RoutingKey,
24532453
arguments = Arguments},
24542454
ConnPid, AuthzContext, _CollectorId, VHostPath, User) ->
2455-
binding_action(fun rabbit_binding:remove/3,
2456-
SourceNameBin, exchange, DestinationNameBin,
2457-
RoutingKey, Arguments, VHostPath, ConnPid, AuthzContext, User);
2455+
binding_action(remove,
2456+
SourceNameBin, exchange, DestinationNameBin,
2457+
RoutingKey, Arguments, VHostPath, ConnPid, AuthzContext, User);
24582458
handle_method(#'queue.unbind'{queue = QueueNameBin,
24592459
exchange = ExchangeNameBin,
24602460
routing_key = RoutingKey,
24612461
arguments = Arguments},
24622462
ConnPid, AuthzContext, _CollectorId, VHostPath, User) ->
2463-
binding_action(fun rabbit_binding:remove/3,
2463+
binding_action(remove,
24642464
ExchangeNameBin, queue, QueueNameBin,
24652465
RoutingKey, Arguments, VHostPath, ConnPid, AuthzContext, User);
24662466
handle_method(#'queue.bind'{queue = QueueNameBin,
24672467
exchange = ExchangeNameBin,
24682468
routing_key = RoutingKey,
24692469
arguments = Arguments},
24702470
ConnPid, AuthzContext, _CollectorId, VHostPath, User) ->
2471-
binding_action(fun rabbit_binding:add/3,
2471+
binding_action(add,
24722472
ExchangeNameBin, queue, QueueNameBin,
24732473
RoutingKey, Arguments, VHostPath, ConnPid, AuthzContext, User);
24742474
%% Note that all declares to these are effectively passive. If it
@@ -2583,12 +2583,12 @@ handle_method(#'queue.declare'{queue = QueueNameBin,
25832583
ConnPid, _AuthzContext, _CollectorPid, VHostPath, _User) ->
25842584
StrippedQueueNameBin = strip_cr_lf(QueueNameBin),
25852585
QueueName = rabbit_misc:r(VHostPath, queue, StrippedQueueNameBin),
2586-
Fun = fun (Q0) ->
2586+
Action = fun (Q0) ->
25872587
QStat = maybe_stat(NoWait, Q0),
25882588
{QStat, Q0}
25892589
end,
25902590
%% Note: no need to check if Q is an #amqqueue, with_or_die does it
2591-
{{ok, MessageCount, ConsumerCount}, Q} = rabbit_amqqueue:with_or_die(QueueName, Fun),
2591+
{{ok, MessageCount, ConsumerCount}, Q} = rabbit_amqqueue:with_or_die(QueueName, Action),
25922592
ok = rabbit_amqqueue:check_exclusive_access(Q, ConnPid),
25932593
{ok, QueueName, MessageCount, ConsumerCount};
25942594
handle_method(#'queue.delete'{queue = QueueNameBin,

0 commit comments

Comments
 (0)