diff options
| author | Daniil Fedotov <hairyhum@gmail.com> | 2018-12-28 17:20:39 +0400 |
|---|---|---|
| committer | Daniil Fedotov <hairyhum@gmail.com> | 2018-12-28 17:20:39 +0400 |
| commit | c7d107dd9fc1a336246f5105574f6c6a5acc2593 (patch) | |
| tree | e2c1dcd4defd7b754b96f1bfce1068ecf0848fb5 /src | |
| parent | 10013f55c653f8fa06e581368fe236a1ad1f894d (diff) | |
| download | rabbitmq-server-git-c7d107dd9fc1a336246f5105574f6c6a5acc2593.tar.gz | |
Add fake bindings to list functions.
Default bindings are not represented in the mnesia database but still
expected in the management UI and the rabbitmqctl command.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_amqqueue.erl | 4 | ||||
| -rw-r--r-- | src/rabbit_binding.erl | 61 |
2 files changed, 51 insertions, 14 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index 246397ea28..f0d5e825d1 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -29,7 +29,7 @@ -export([list/0, list/1, info_keys/0, info/1, info/2, info_all/1, info_all/2, emit_info_all/5, list_local/1, info_local/1, emit_info_local/4, emit_info_down/4]). --export([list_down/1, count/1, list_names/0, list_local_names/0]). +-export([list_down/1, count/1, list_names/0, list_names/1, list_local_names/0]). -export([list_by_type/1]). -export([notify_policy_changed/1]). -export([consumers/1, consumers_all/1, emit_consumers_all/4, consumer_info_keys/0]). @@ -747,6 +747,8 @@ list() -> mnesia:dirty_match_object(rabbit_queue, #amqqueue{_ = '_'}). list_names() -> mnesia:dirty_all_keys(rabbit_queue). +list_names(VHost) -> [Q#amqqueue.name || Q <- list(VHost)]. + list_local_names() -> [ Q#amqqueue.name || #amqqueue{state = State, pid = QPid} = Q <- list(), State =/= crashed, is_local_to_node(QPid, node())]. diff --git a/src/rabbit_binding.erl b/src/rabbit_binding.erl index e96dfd7673..873d5c64d3 100644 --- a/src/rabbit_binding.erl +++ b/src/rabbit_binding.erl @@ -243,9 +243,14 @@ list(VHostPath) -> destination = VHostResource, _ = '_'}, _ = '_'}, - [B || #route{binding = B} <- mnesia:dirty_match_object(rabbit_route, - Route)]. - + implicit_bindings(VHostPath) ++ + [B || #route{binding = B} <- mnesia:dirty_match_object(rabbit_route, + Route)]. + +list_for_source(#resource{kind = exchange, + virtual_host = VHostPath, + name = <<>>}) -> + implicit_bindings(VHostPath); list_for_source(SrcName) -> mnesia:async_dirty( fun() -> @@ -255,16 +260,46 @@ list_for_source(SrcName) -> end). list_for_destination(DstName) -> - mnesia:async_dirty( - fun() -> - Route = #route{binding = #binding{destination = DstName, - _ = '_'}}, - [reverse_binding(B) || - #reverse_route{reverse_binding = B} <- - mnesia:match_object(rabbit_reverse_route, - reverse_route(Route), read)] - end). - + implicit_for_destination(DstName) ++ + mnesia:async_dirty( + fun() -> + Route = #route{binding = #binding{destination = DstName, + _ = '_'}}, + [reverse_binding(B) || + #reverse_route{reverse_binding = B} <- + mnesia:match_object(rabbit_reverse_route, + reverse_route(Route), read)] + end). + +implicit_bindings(VHostPath) -> + DstQueues = rabbit_amqqueue:list_names(VHostPath), + DefaultExchange = #resource{virtual_host = VHostPath, + kind = exchange, + name = <<>>}, + [ #binding{source = DefaultExchange, + destination = DstQueue, + key = QName} + || DstQueue = #resource{name = QName} <- DstQueues ]. + +implicit_for_destination(DstQueue = #resource{kind = queue, + virtual_host = VHostPath, + name = QName}) -> + DefaultExchange = #resource{virtual_host = VHostPath, + kind = exchange, + name = <<>>}, + [#binding{source = DefaultExchange, + destination = DstQueue, + key = QName}]; +implicit_for_destination(_) -> + []. + +list_for_source_and_destination(#resource{kind = exchange, + virtual_host = VHostPath, + name = <<>>} = DefaultExchange, + #resource{kind = queue, + virtual_host = VHostPath, + name = QName} = DstQueue) -> + [#binding{source = DefaultExchange, destination = DstQueue, key = QName}]; list_for_source_and_destination(SrcName, DstName) -> mnesia:async_dirty( fun() -> |
