summaryrefslogtreecommitdiff
path: root/src/rabbit_router.erl
diff options
context:
space:
mode:
authorEmile Joubert <emile@rabbitmq.com>2011-02-22 14:43:08 +0000
committerEmile Joubert <emile@rabbitmq.com>2011-02-22 14:43:08 +0000
commit102eb1221e34274c2fa54595d3c2fd258645f410 (patch)
tree285cea32afeca2eefd2ef437fe14bcdab1541d54 /src/rabbit_router.erl
parentae7bd1fae91979e83e462bb1d0fec41f0b65bceb (diff)
downloadrabbitmq-server-102eb1221e34274c2fa54595d3c2fd258645f410.tar.gz
Sender-specified destinations updates
build on R12B3 reduce mnesia lookups
Diffstat (limited to 'src/rabbit_router.erl')
-rw-r--r--src/rabbit_router.erl17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/rabbit_router.erl b/src/rabbit_router.erl
index 692d2473..53e707f4 100644
--- a/src/rabbit_router.erl
+++ b/src/rabbit_router.erl
@@ -37,7 +37,8 @@
fun ((rabbit_types:binding()) -> boolean())) ->
match_result()).
-spec(match_routing_key/2 :: (rabbit_types:binding_source(),
- routing_key() | '_') -> match_result()).
+ [routing_key()] | ['_']) ->
+ match_result()).
-endif.
@@ -82,12 +83,22 @@ match_bindings(SrcName, Match) ->
Match(Binding)]),
mnesia:async_dirty(fun qlc:e/1, [Query]).
-match_routing_key(SrcName, RoutingKey) ->
+match_routing_key(SrcName, [RoutingKey]) ->
MatchHead = #route{binding = #binding{source = SrcName,
destination = '$1',
key = RoutingKey,
_ = '_'}},
- mnesia:dirty_select(rabbit_route, [{MatchHead, [], ['$1']}]).
+ mnesia:dirty_select(rabbit_route, [{MatchHead, [], ['$1']}]);
+match_routing_key(SrcName, [_|_] = RoutingKeys) ->
+ Condition = list_to_tuple(['orelse' | [{'=:=', '$2', RKey} ||
+ RKey <- RoutingKeys]]),
+ MatchHead = #route{binding = #binding{source = SrcName,
+ destination = '$1',
+ key = '$2',
+ _ = '_'}},
+ mnesia:dirty_select(rabbit_route, [{MatchHead, [Condition], ['$1']}]).
+
+
%%--------------------------------------------------------------------