chore: add emqx_management_proto_v4

This commit is contained in:
JianBo He 2023-05-30 21:46:33 +08:00
parent fc806c4acd
commit 48c53d8b32
4 changed files with 89 additions and 9 deletions

View File

@ -2,7 +2,7 @@
{application, emqx_management, [ {application, emqx_management, [
{description, "EMQX Management API and CLI"}, {description, "EMQX Management API and CLI"},
% strict semver, bump manually! % strict semver, bump manually!
{vsn, "5.0.23"}, {vsn, "5.0.24"},
{modules, []}, {modules, []},
{registered, [emqx_management_sup]}, {registered, [emqx_management_sup]},
{applications, [kernel, stdlib, emqx_plugins, minirest, emqx, emqx_ctl]}, {applications, [kernel, stdlib, emqx_plugins, minirest, emqx, emqx_ctl]},

View File

@ -326,7 +326,7 @@ kickout_client(Node, ClientId) ->
kickout_clients(ClientIds) when is_list(ClientIds) -> kickout_clients(ClientIds) when is_list(ClientIds) ->
F = fun(Node) -> F = fun(Node) ->
emqx_management_proto_v3:kickout_clients(Node, ClientIds) emqx_management_proto_v4:kickout_clients(Node, ClientIds)
end, end,
Results = lists:map(F, emqx:running_nodes()), Results = lists:map(F, emqx:running_nodes()),
case lists:filter(fun(Res) -> Res =/= ok end, Results) of case lists:filter(fun(Res) -> Res =/= ok end, Results) of

View File

@ -32,9 +32,7 @@
call_client/3, call_client/3,
get_full_config/1, get_full_config/1
kickout_clients/2
]). ]).
-include_lib("emqx/include/bpapi.hrl"). -include_lib("emqx/include/bpapi.hrl").
@ -80,7 +78,3 @@ call_client(Node, ClientId, Req) ->
-spec get_full_config(node()) -> map() | list() | {badrpc, _}. -spec get_full_config(node()) -> map() | list() | {badrpc, _}.
get_full_config(Node) -> get_full_config(Node) ->
rpc:call(Node, emqx_mgmt_api_configs, get_full_config, []). rpc:call(Node, emqx_mgmt_api_configs, get_full_config, []).
-spec kickout_clients(node(), [emqx_types:clientid()]) -> ok | {badrpc, _}.
kickout_clients(Node, ClientIds) ->
rpc:call(Node, emqx_mgmt, do_kickout_clients, [ClientIds]).

View File

@ -0,0 +1,86 @@
%%--------------------------------------------------------------------
%% Copyright (c) 2022-2023 EMQ Technologies Co., Ltd. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%--------------------------------------------------------------------
-module(emqx_management_proto_v4).
-behaviour(emqx_bpapi).
-export([
introduced_in/0,
node_info/1,
broker_info/1,
list_subscriptions/1,
list_listeners/1,
subscribe/3,
unsubscribe/3,
unsubscribe_batch/3,
call_client/3,
get_full_config/1,
kickout_clients/2
]).
-include_lib("emqx/include/bpapi.hrl").
introduced_in() ->
"5.1.0".
-spec unsubscribe_batch(node(), emqx_types:clientid(), [emqx_types:topic()]) ->
{unsubscribe, _} | {error, _} | {badrpc, _}.
unsubscribe_batch(Node, ClientId, Topics) ->
rpc:call(Node, emqx_mgmt, do_unsubscribe_batch, [ClientId, Topics]).
-spec node_info([node()]) -> emqx_rpc:erpc_multicall(map()).
node_info(Nodes) ->
erpc:multicall(Nodes, emqx_mgmt, node_info, [], 30000).
-spec broker_info([node()]) -> emqx_rpc:erpc_multicall(map()).
broker_info(Nodes) ->
erpc:multicall(Nodes, emqx_mgmt, broker_info, [], 30000).
-spec list_subscriptions(node()) -> [map()] | {badrpc, _}.
list_subscriptions(Node) ->
rpc:call(Node, emqx_mgmt, do_list_subscriptions, []).
-spec list_listeners(node()) -> map() | {badrpc, _}.
list_listeners(Node) ->
rpc:call(Node, emqx_mgmt_api_listeners, do_list_listeners, []).
-spec subscribe(node(), emqx_types:clientid(), emqx_types:topic_filters()) ->
{subscribe, _} | {error, atom()} | {badrpc, _}.
subscribe(Node, ClientId, TopicTables) ->
rpc:call(Node, emqx_mgmt, do_subscribe, [ClientId, TopicTables]).
-spec unsubscribe(node(), emqx_types:clientid(), emqx_types:topic()) ->
{unsubscribe, _} | {error, _} | {badrpc, _}.
unsubscribe(Node, ClientId, Topic) ->
rpc:call(Node, emqx_mgmt, do_unsubscribe, [ClientId, Topic]).
-spec call_client(node(), emqx_types:clientid(), term()) -> term().
call_client(Node, ClientId, Req) ->
rpc:call(Node, emqx_mgmt, do_call_client, [ClientId, Req]).
-spec get_full_config(node()) -> map() | list() | {badrpc, _}.
get_full_config(Node) ->
rpc:call(Node, emqx_mgmt_api_configs, get_full_config, []).
-spec kickout_clients(node(), [emqx_types:clientid()]) -> ok | {badrpc, _}.
kickout_clients(Node, ClientIds) ->
rpc:call(Node, emqx_mgmt, do_kickout_clients, [ClientIds]).