|
13 | 13 | -export([recover/0, recover/1, read_config/1]). |
14 | 14 | -export([add/2, add/4, delete/2, exists/1, with/2, with_user_and_vhost/3, assert/1, update/2, |
15 | 15 | 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]). |
17 | 17 | -export([parse_tags/1, update_metadata/2, tag_with/2, untag_from/2, update_tags/2, update_tags/3]). |
18 | 18 | -export([lookup/1]). |
19 | 19 | -export([info/1, info/2, info_all/0, info_all/1, info_all/2, info_all/3]). |
@@ -401,6 +401,18 @@ list() -> list_names(). |
401 | 401 | -spec all() -> [vhost:vhost()]. |
402 | 402 | all() -> mnesia:dirty_match_object(rabbit_vhost, vhost:pattern_match_all()). |
403 | 403 |
|
| 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 | + |
404 | 416 | -spec count() -> non_neg_integer(). |
405 | 417 | count() -> |
406 | 418 | length(list()). |
|
0 commit comments