Skip to content

Commit 71d3017

Browse files
kjnilssonmkuratczyk
authored andcommitted
faster
1 parent ee592bf commit 71d3017

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

deps/rabbit/src/rabbit_exchange_type_local_random.erl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ description() ->
3838
{description, <<"Picks one random local binding (queue) to route via (to).">>}].
3939

4040
route(#exchange{name = Name}, _Msg, _Opts) ->
41-
Matches = rabbit_router:match_routing_key(Name, ['_']),
41+
Matches = rabbit_router:match_routing_key(Name, [<<>>]),
4242
case lists:filter(fun filter_local_queue/1, Matches) of
4343
[] ->
4444
[];
@@ -59,8 +59,9 @@ delete(_Serial, _X) -> ok.
5959
policy_changed(_X1, _X2) -> ok.
6060
add_binding(_Serial, _X, _B) -> ok.
6161
remove_bindings(_Serial, _X, _Bs) -> ok.
62-
validate_binding(_X, #binding{destination = Dest}) ->
63-
%% check destination is a classic queue
62+
63+
validate_binding(_X, #binding{destination = Dest,
64+
key = <<>>}) ->
6465
case rabbit_amqqueue:lookup(Dest) of
6566
{ok, Q} ->
6667
case amqqueue:get_type(Q) of
@@ -75,12 +76,17 @@ validate_binding(_X, #binding{destination = Dest}) ->
7576
{error, {binding_invalid,
7677
"Destination not found",
7778
[]}}
78-
end.
79+
end;
80+
validate_binding(_X, #binding{key = BKey}) ->
81+
{error, {binding_invalid,
82+
"Non empty binding '~s' key not permitted",
83+
[BKey]}}.
7984

8085
assert_args_equivalence(X, Args) ->
8186
rabbit_exchange:assert_args_equivalence(X, Args).
8287

8388
filter_local_queue(QName) ->
89+
%% TODO: introduce lookup function that _only_ gets the pid
8490
case rabbit_amqqueue:lookup(QName) of
8591
{ok, Q} ->
8692
case amqqueue:get_pid(Q) of

0 commit comments

Comments
 (0)