diff options
| author | Matthias Radestock <matthias@lshift.net> | 2008-09-26 20:17:03 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2008-09-26 20:17:03 +0100 |
| commit | fcf48b3d9a271fcbee9701825b433e5292c205b6 (patch) | |
| tree | 730775240a77a83286b21b5a4cc9f44271d8dcb1 | |
| parent | c250b7b89c70a0618457325c86c3102b85b079b9 (diff) | |
| download | rabbitmq-server-git-fcf48b3d9a271fcbee9701825b433e5292c205b6.tar.gz | |
simplify select
| -rw-r--r-- | src/rabbit_exchange.erl | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index 52a6dbddec..d362f4e90a 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -212,25 +212,14 @@ route(#exchange{name = Name, type = topic}, RoutingKey) -> topic_matches(BindingKey, RoutingKey)]), lookup_qpids(mnesia:activity(async_dirty, fun() -> qlc:e(Query) end)); -% This mnesia:select is complicated because the exchange component of the -% match head cannot be matched against a tuple. Hence I had to decompose -% a tuple match for an exchange into individual matches for its constituent -% parts. For reference, the code that does not seem to work is this: -% ... -% MatchHead = #route{binding = #binding{exchange_name = $1, -% queue_name = '$3', -% key = '$2'}}, -% Guards = [{'==', '$1', Name}, {'==', '$2', RoutingKey}], -% ... -route(#exchange{name = #resource{name = Name, virtual_host = VHostPath}}, RoutingKey) -> - Exchange = #resource{kind = exchange, name ='$1', virtual_host = '$2'}, - MatchHead = #route{binding = #binding{exchange_name = Exchange, - queue_name = '$3', - key = '$4'}}, - Guards = [{'==', '$1', Name}, {'==', '$2', VHostPath}, {'==', '$4', RoutingKey}], - lookup_qpids(mnesia:activity(async_dirty, - fun() -> mnesia:select(route, [{MatchHead, Guards, ['$3']}]) - end)). +route(#exchange{name = Name}, RoutingKey) -> + MatchHead = #route{binding = #binding{exchange_name = Name, + key = RoutingKey, + queue_name = '$1'}}, + lookup_qpids( + mnesia:activity( + async_dirty, + fun() -> mnesia:select(route, [{MatchHead, [], ['$1']}]) end)). lookup_qpids(Queues) -> Set = sets:from_list(Queues), |
