|
46 | 46 |
|
47 | 47 | %% Used by on_node_up and on_node_down. |
48 | 48 | %% Can be deleted once transient entities/mnesia are removed. |
49 | | --export([foreach_transient/1, |
| 49 | +-export([list_transient/0, |
| 50 | + foreach_transient/1, |
50 | 51 | delete_transient/1]). |
51 | 52 |
|
52 | 53 | %% Only used by rabbit_amqqueue:forget_node_for_queue, which is only called |
@@ -965,6 +966,40 @@ set_in_khepri(Q) -> |
965 | 966 | Path = khepri_queue_path(amqqueue:get_name(Q)), |
966 | 967 | rabbit_khepri:put(Path, Q). |
967 | 968 |
|
| 969 | +%% ------------------------------------------------------------------- |
| 970 | +%% list_transient(). |
| 971 | +%% ------------------------------------------------------------------- |
| 972 | + |
| 973 | +-spec list_transient() -> {ok, Queues} | {error, any()} when |
| 974 | + Queues :: [amqqueue:amqqueue()]. |
| 975 | +%% @doc Applies `UpdateFun' to all transient queue records. |
| 976 | +%% |
| 977 | +%% @private |
| 978 | + |
| 979 | +list_transient() -> |
| 980 | + rabbit_khepri:handle_fallback( |
| 981 | + #{mnesia => fun() -> list_transient_in_mnesia() end, |
| 982 | + khepri => fun() -> list_transient_in_khepri() end |
| 983 | + }). |
| 984 | + |
| 985 | +list_transient_in_mnesia() -> |
| 986 | + Pattern = amqqueue:pattern_match_all(), |
| 987 | + AllQueues = mnesia:dirty_match_object( |
| 988 | + ?MNESIA_TABLE, |
| 989 | + Pattern), |
| 990 | + {ok, AllQueues}. |
| 991 | + |
| 992 | +list_transient_in_khepri() -> |
| 993 | + try |
| 994 | + List = ets:match_object( |
| 995 | + ?KHEPRI_PROJECTION, |
| 996 | + amqqueue:pattern_match_on_durable(false)), |
| 997 | + {ok, List} |
| 998 | + catch |
| 999 | + error:badarg -> |
| 1000 | + {error, {khepri_projection_missing, ?KHEPRI_WILDCARD_STAR}} |
| 1001 | + end. |
| 1002 | + |
968 | 1003 | %% ------------------------------------------------------------------- |
969 | 1004 | %% delete_transient(). |
970 | 1005 | %% ------------------------------------------------------------------- |
|
0 commit comments