Skip to content

Commit 3ae354b

Browse files
rabbit_vhost: introduce all_tagged_with/1
(cherry picked from commit a4cc096)
1 parent 7f271ae commit 3ae354b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

deps/rabbit/src/rabbit_vhost.erl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
-export([recover/0, recover/1, read_config/1]).
1414
-export([add/2, add/4, delete/2, exists/1, with/2, with_user_and_vhost/3, assert/1, update/2,
1515
set_limits/2, vhost_cluster_state/1, is_running_on_all_nodes/1, await_running_on_all_nodes/2,
16-
list/0, count/0, list_names/0, all/0]).
16+
list/0, count/0, list_names/0, all/0, all_tagged_with/1]).
1717
-export([parse_tags/1, update_metadata/2, tag_with/2, untag_from/2, update_tags/2, update_tags/3]).
1818
-export([lookup/1]).
1919
-export([info/1, info/2, info_all/0, info_all/1, info_all/2, info_all/3]).
@@ -401,6 +401,18 @@ list() -> list_names().
401401
-spec all() -> [vhost:vhost()].
402402
all() -> mnesia:dirty_match_object(rabbit_vhost, vhost:pattern_match_all()).
403403

404+
-spec all_tagged_with(atom()) -> [vhost:vhost()].
405+
all_tagged_with(TagName) ->
406+
lists:filter(
407+
fun(VHost) ->
408+
Meta = vhost:get_metadata(VHost),
409+
case Meta of
410+
#{tags := Tags} ->
411+
lists:member(rabbit_data_coercion:to_atom(TagName), Tags);
412+
_ -> false
413+
end
414+
end, all()).
415+
404416
-spec count() -> non_neg_integer().
405417
count() ->
406418
length(list()).

0 commit comments

Comments
 (0)