Add clear cache command

This commit is contained in:
Marcial Rosales 2025-02-12 16:55:31 +01:00
parent e8a302a249
commit b0a9f145e1
2 changed files with 85 additions and 0 deletions

View File

@ -19,6 +19,8 @@ endef
DEPS = rabbit_common rabbit
TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers
PLT_APPS += rabbitmqctl
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk

View File

@ -0,0 +1,83 @@
%% This Source Code Form is subject to the terms of the Mozilla Public
%% License, v. 2.0. If a copy of the MPL was not distributed with this
%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
%%
%% Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term Broadcom refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
%%
-module('Elixir.RabbitMQ.CLI.Ctl.Commands.AuthClearCacheCommand').
-behaviour('Elixir.RabbitMQ.CLI.CommandBehaviour').
-export([
usage/0,
usage_additional/0,
usage_doc_guides/0,
flags/0,
validate/2,
merge_defaults/2,
banner/2,
run/2,
switches/0,
aliases/0,
output/2,
scopes/0,
formatter/0,
help_section/0,
description/0
]).
%%----------------------------------------------------------------------------
%% Callbacks
%%----------------------------------------------------------------------------
scopes() ->
[vmware, ctl].
switches() ->
[].
usage() ->
<<"auth_clear_cache">>.
usage_additional() ->
[].
usage_doc_guides() ->
[].
help_section() ->
{plugin, rabbitmq_auth_backend_cache}.
description() ->
<<"Clear cache of authorization decisions">>.
flags() ->
[].
validate(_, _) ->
ok.
formatter() ->
'Elixir.RabbitMQ.CLI.Formatters.Table'.
merge_defaults(A, O) ->
{A, O}.
banner(_, _) ->
erlang:iolist_to_binary([<<"Will delete all cached authorization decisions">>]).
run(_Args, #{node := Node}) ->
case rabbit_misc:rpc_call(Node, rabbit_auth_backend_cache, clear_cache_cluster_wide, []) of
{badrpc, _} = Error ->
Error;
Deleted ->
Deleted
end.
aliases() ->
[].
output(Value, _Opts) ->
'Elixir.RabbitMQ.CLI.DefaultOutput':output(Value).