chore: add invite_node/2 bpapi
This commit is contained in:
parent
7799600271
commit
5acf19a947
|
@ -21,3 +21,4 @@
|
|||
{emqx_telemetry,1}.
|
||||
{emqx_topic_metrics,1}.
|
||||
{emqx_delayed,1}.
|
||||
{emqx_mgmt_cluster,1}.
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
-include_lib("hocon/include/hoconsc.hrl").
|
||||
|
||||
-export([api_spec/0, fields/1, paths/0, schema/1, namespace/0]).
|
||||
-export([cluster_info/2, invite_node/2, force_leave/2]).
|
||||
-export([cluster_info/2, invite_node/2, force_leave/2, join/1]).
|
||||
|
||||
namespace() -> "cluster".
|
||||
|
||||
|
@ -103,7 +103,7 @@ cluster_info(get, _) ->
|
|||
|
||||
invite_node(put, #{bindings := #{node := Node0}}) ->
|
||||
Node = ekka_node:parse_name(binary_to_list(Node0)),
|
||||
case rpc:call(Node, ekka, join, [node()]) of
|
||||
case emqx_mgmt_cluster_proto_v1:invite_node(Node, node()) of
|
||||
ok ->
|
||||
{200};
|
||||
ignore ->
|
||||
|
@ -125,5 +125,9 @@ force_leave(delete, #{bindings := #{node := Node0}}) ->
|
|||
{400, #{code => 'BAD_REQUEST', message => error_message(Error)}}
|
||||
end.
|
||||
|
||||
-spec(join(node()) -> ok | ignore | {error, term()}).
|
||||
join(Node) ->
|
||||
ekka:join(Node).
|
||||
|
||||
error_message(Msg) ->
|
||||
iolist_to_binary(io_lib:format("~p", [Msg])).
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
%%--------------------------------------------------------------------
|
||||
%% Copyright (c) 2022 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_mgmt_cluster_proto_v1).
|
||||
|
||||
-behaviour(emqx_bpapi).
|
||||
|
||||
-export([
|
||||
introduced_in/0,
|
||||
invite_node/2
|
||||
]).
|
||||
|
||||
-include_lib("emqx/include/bpapi.hrl").
|
||||
|
||||
introduced_in() ->
|
||||
"5.0.0".
|
||||
|
||||
-spec invite_node(node(), node()) -> ok | ignore | {error, term()} | emqx_rpc:badrpc().
|
||||
invite_node(Node, Self) ->
|
||||
rpc:call(Node, emqx_mgmt_api_cluster, join, [Self], 5000).
|
Loading…
Reference in New Issue