diff options
author | Ben Hood <0x6e6562@gmail.com> | 2008-10-13 19:12:16 +0100 |
---|---|---|
committer | Ben Hood <0x6e6562@gmail.com> | 2008-10-13 19:12:16 +0100 |
commit | 0082c893c2b527c48f054f696c48b0c601c58660 (patch) | |
tree | e7bf748f6834f6e0e22337077e6e0970f92b4246 | |
parent | 88a8e55e6f2685d6c23f3ba53ea96c498404434d (diff) | |
download | rabbitmq-server-0082c893c2b527c48f054f696c48b0c601c58660.tar.gz |
Used record wildcard match feature
-rw-r--r-- | src/rabbit_exchange.erl | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index 2dcaf791..5c4be4ef 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -209,7 +209,7 @@ route_internal(#exchange{name = Name}, RoutingKey) -> MatchHead = #route{binding = #binding{exchange_name = Name, queue_name = '$1', key = RoutingKey, - args = '_'}}, + _ = '_'}}, lookup_qpids(mnesia:dirty_select(route, [{MatchHead, [], ['$1']}])). lookup_qpids(Queues) -> @@ -226,18 +226,14 @@ lookup_qpids(Queues) -> delete_bindings_for_exchange(ExchangeName) -> indexed_delete( #route{binding = #binding{exchange_name = ExchangeName, - queue_name = '_', - key = '_', - args = '_'}}, + _ = '_'}}, fun delete_forward_routes/1, fun mnesia:delete_object/1). delete_bindings_for_queue(QueueName) -> Exchanges = exchanges_for_queue(QueueName), indexed_delete( - reverse_route(#route{binding = #binding{exchange_name = '_', - queue_name = QueueName, - key = '_', - args = '_'}}), + reverse_route(#route{binding = #binding{ queue_name = QueueName, + _ = '_'}}), fun mnesia:delete_object/1, fun delete_forward_routes/1), [begin [X] = mnesia:read({exchange, ExchangeName}), @@ -260,8 +256,7 @@ exchanges_for_queue(QueueName) -> MatchHead = reverse_route( #route{binding = #binding{exchange_name = '$1', queue_name = QueueName, - key = '_', - args = '_'}}), + _ = '_'}}), sets:to_list( sets:from_list( mnesia:select(reverse_route, [{MatchHead, [], ['$1']}]))). @@ -269,8 +264,7 @@ exchanges_for_queue(QueueName) -> has_bindings(ExchangeName) -> MatchHead = #route{binding = #binding{exchange_name = ExchangeName, queue_name = '$1', - key = '_', - args = '_'}}, + _ = '_'}}, continue(mnesia:select(route, [{MatchHead, [], ['$1']}], 1, read)). continue('$end_of_table') -> false; @@ -417,9 +411,7 @@ unconditional_delete(#exchange{name = ExchangeName}) -> %% return {QueueName, RoutingKey, Arguments} tuples list_exchange_bindings(ExchangeName) -> Route = #route{binding = #binding{exchange_name = ExchangeName, - queue_name = '_', - key = '_', - args = '_'}}, + _ = '_'}}, [{QueueName, RoutingKey, Arguments} || #route{binding = #binding{queue_name = QueueName, key = RoutingKey, |