diff options
| author | Michael Klishin <klishinm@vmware.com> | 2022-06-27 16:42:14 +0400 |
|---|---|---|
| committer | Michael Klishin <klishinm@vmware.com> | 2022-06-27 16:42:14 +0400 |
| commit | 088b7a63a9ecb6b356257297e45fe6d75c4aa3c6 (patch) | |
| tree | 7ef6e410a311ad168132457e5be7becb41082e95 | |
| parent | f07003b0c5a90ba0f94f9fe1ccf969bedd9e7b59 (diff) | |
| download | rabbitmq-server-git-088b7a63a9ecb6b356257297e45fe6d75c4aa3c6.tar.gz | |
Introduce rabbit_binding:list_between/2
and has_any_between/2
| -rw-r--r-- | deps/rabbit/src/rabbit_binding.erl | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/deps/rabbit/src/rabbit_binding.erl b/deps/rabbit/src/rabbit_binding.erl index 8a15b302d3..820fc845a2 100644 --- a/deps/rabbit/src/rabbit_binding.erl +++ b/deps/rabbit/src/rabbit_binding.erl @@ -11,7 +11,8 @@ -export([recover/0, recover/2, exists/1, add/2, add/3, remove/1, remove/2, remove/3, remove/4]). -export([list/1, list_for_source/1, list_for_destination/1, - list_for_source_and_destination/2, list_explicit/0]). + list_for_source_and_destination/2, list_explicit/0, + list_between/2, has_any_between/2]). -export([new_deletions/0, combine_deletions/2, add_deletion/3, process_deletions/2, binding_action/3]). -export([info_keys/0, info/1, info/2, info_all/1, info_all/2, info_all/4]). @@ -304,6 +305,30 @@ list_for_destination(DstName = #resource{virtual_host = VHostPath}) -> end, AllBindings), implicit_for_destination(DstName) ++ Filtered. +-spec list_between( + rabbit_types:binding_source(), + rabbit_types:binding_destination()) -> bindings(). + +list_between(SrcName = #resource{virtual_host = SVH}, DstName = #resource{}) -> + AllBindings = mnesia:async_dirty( + fun() -> + Route = #route{binding = #binding{ + source = SrcName, + destination = DstName, + _ = '_'} + }, + [B || #route{binding = B} + <- mnesia:match_object(rabbit_route, Route, read)] + end), + lists:filter(fun(#binding{source = S}) -> + S =/= ?DEFAULT_EXCHANGE(SVH) + end, AllBindings). + +-spec has_any_between(rabbit_types:binding_source(), + rabbit_types:binding_destination()) -> boolean(). +has_any_between(Source, Destination) -> + list_between(Source, Destination) =/= []. + implicit_bindings(VHostPath) -> DstQueues = rabbit_amqqueue:list_names(VHostPath), [ #binding{source = ?DEFAULT_EXCHANGE(VHostPath), |
