chore: update emqx_conf.appup.src
This commit is contained in:
parent
c23ccbd370
commit
cbf467ee3d
|
@ -1,10 +1,21 @@
|
||||||
%% Unless you know what you are doing, DO NOT edit manually!!
|
%% -*- mode: erlang -*-
|
||||||
{VSN,
|
{VSN,
|
||||||
[{"0.1.0",
|
[ {"0.1.0",
|
||||||
[{load_module,emqx_conf_schema,brutal_purge,soft_purge,[]},
|
[
|
||||||
{load_module,emqx_conf,brutal_purge,soft_purge,[]}]},
|
{add_module, emqx_conf_proto_v2},
|
||||||
{<<".*">>,[]}],
|
{load_module,emqx_conf_schema,brutal_purge,soft_purge,[]},
|
||||||
[{"0.1.0",
|
{load_module,emqx_conf,brutal_purge,soft_purge,[]},
|
||||||
[{load_module,emqx_conf_schema,brutal_purge,soft_purge,[]},
|
{load_module,emqx_conf_app,brutal_purge,soft_purge,[]}
|
||||||
{load_module,emqx_conf,brutal_purge,soft_purge,[]}]},
|
]},
|
||||||
{<<".*">>,[]}]}.
|
{<<".*">>, []}
|
||||||
|
],
|
||||||
|
[ {"0.1.0",
|
||||||
|
[
|
||||||
|
{delete_module, emqx_conf_proto_v2},
|
||||||
|
{load_module,emqx_conf_schema,brutal_purge,soft_purge,[]},
|
||||||
|
{load_module,emqx_conf,brutal_purge,soft_purge,[]},
|
||||||
|
{load_module,emqx_conf_app,brutal_purge,soft_purge,[]}
|
||||||
|
]},
|
||||||
|
{<<".*">>, []}
|
||||||
|
]
|
||||||
|
}.
|
||||||
|
|
|
@ -62,7 +62,7 @@ get_raw(KeyPath) ->
|
||||||
%% @doc Returns all values in the cluster.
|
%% @doc Returns all values in the cluster.
|
||||||
-spec get_all(emqx_map_lib:config_key_path()) -> #{node() => term()}.
|
-spec get_all(emqx_map_lib:config_key_path()) -> #{node() => term()}.
|
||||||
get_all(KeyPath) ->
|
get_all(KeyPath) ->
|
||||||
{ResL, []} = emqx_conf_proto_v1:get_all(KeyPath),
|
{ResL, []} = emqx_conf_proto_v2:get_all(KeyPath),
|
||||||
maps:from_list(ResL).
|
maps:from_list(ResL).
|
||||||
|
|
||||||
%% @doc Returns the specified node's KeyPath, or exception if not found
|
%% @doc Returns the specified node's KeyPath, or exception if not found
|
||||||
|
@ -70,14 +70,14 @@ get_all(KeyPath) ->
|
||||||
get_by_node(Node, KeyPath) when Node =:= node() ->
|
get_by_node(Node, KeyPath) when Node =:= node() ->
|
||||||
emqx:get_config(KeyPath);
|
emqx:get_config(KeyPath);
|
||||||
get_by_node(Node, KeyPath) ->
|
get_by_node(Node, KeyPath) ->
|
||||||
emqx_conf_proto_v1:get_config(Node, KeyPath).
|
emqx_conf_proto_v2:get_config(Node, KeyPath).
|
||||||
|
|
||||||
%% @doc Returns the specified node's KeyPath, or the default value if not found
|
%% @doc Returns the specified node's KeyPath, or the default value if not found
|
||||||
-spec get_by_node(node(), emqx_map_lib:config_key_path(), term()) -> term().
|
-spec get_by_node(node(), emqx_map_lib:config_key_path(), term()) -> term().
|
||||||
get_by_node(Node, KeyPath, Default) when Node =:= node() ->
|
get_by_node(Node, KeyPath, Default) when Node =:= node() ->
|
||||||
emqx:get_config(KeyPath, Default);
|
emqx:get_config(KeyPath, Default);
|
||||||
get_by_node(Node, KeyPath, Default) ->
|
get_by_node(Node, KeyPath, Default) ->
|
||||||
emqx_conf_proto_v1:get_config(Node, KeyPath, Default).
|
emqx_conf_proto_v2:get_config(Node, KeyPath, Default).
|
||||||
|
|
||||||
%% @doc Returns the specified node's KeyPath, or config_not_found if key path not found
|
%% @doc Returns the specified node's KeyPath, or config_not_found if key path not found
|
||||||
-spec get_node_and_config(emqx_map_lib:config_key_path()) -> term().
|
-spec get_node_and_config(emqx_map_lib:config_key_path()) -> term().
|
||||||
|
@ -92,7 +92,7 @@ get_node_and_config(KeyPath) ->
|
||||||
) ->
|
) ->
|
||||||
{ok, emqx_config:update_result()} | {error, emqx_config:update_error()}.
|
{ok, emqx_config:update_result()} | {error, emqx_config:update_error()}.
|
||||||
update(KeyPath, UpdateReq, Opts) ->
|
update(KeyPath, UpdateReq, Opts) ->
|
||||||
emqx_conf_proto_v1:update(KeyPath, UpdateReq, Opts).
|
emqx_conf_proto_v2:update(KeyPath, UpdateReq, Opts).
|
||||||
|
|
||||||
%% @doc Update the specified node's key path in local-override.conf.
|
%% @doc Update the specified node's key path in local-override.conf.
|
||||||
-spec update(
|
-spec update(
|
||||||
|
@ -105,13 +105,13 @@ update(KeyPath, UpdateReq, Opts) ->
|
||||||
update(Node, KeyPath, UpdateReq, Opts0) when Node =:= node() ->
|
update(Node, KeyPath, UpdateReq, Opts0) when Node =:= node() ->
|
||||||
emqx:update_config(KeyPath, UpdateReq, Opts0#{override_to => local});
|
emqx:update_config(KeyPath, UpdateReq, Opts0#{override_to => local});
|
||||||
update(Node, KeyPath, UpdateReq, Opts) ->
|
update(Node, KeyPath, UpdateReq, Opts) ->
|
||||||
emqx_conf_proto_v1:update(Node, KeyPath, UpdateReq, Opts).
|
emqx_conf_proto_v2:update(Node, KeyPath, UpdateReq, Opts).
|
||||||
|
|
||||||
%% @doc remove all value of key path in cluster-override.conf or local-override.conf.
|
%% @doc remove all value of key path in cluster-override.conf or local-override.conf.
|
||||||
-spec remove(emqx_map_lib:config_key_path(), emqx_config:update_opts()) ->
|
-spec remove(emqx_map_lib:config_key_path(), emqx_config:update_opts()) ->
|
||||||
{ok, emqx_config:update_result()} | {error, emqx_config:update_error()}.
|
{ok, emqx_config:update_result()} | {error, emqx_config:update_error()}.
|
||||||
remove(KeyPath, Opts) ->
|
remove(KeyPath, Opts) ->
|
||||||
emqx_conf_proto_v1:remove_config(KeyPath, Opts).
|
emqx_conf_proto_v2:remove_config(KeyPath, Opts).
|
||||||
|
|
||||||
%% @doc remove the specified node's key path in local-override.conf.
|
%% @doc remove the specified node's key path in local-override.conf.
|
||||||
-spec remove(node(), emqx_map_lib:config_key_path(), emqx_config:update_opts()) ->
|
-spec remove(node(), emqx_map_lib:config_key_path(), emqx_config:update_opts()) ->
|
||||||
|
@ -119,13 +119,13 @@ remove(KeyPath, Opts) ->
|
||||||
remove(Node, KeyPath, Opts) when Node =:= node() ->
|
remove(Node, KeyPath, Opts) when Node =:= node() ->
|
||||||
emqx:remove_config(KeyPath, Opts#{override_to => local});
|
emqx:remove_config(KeyPath, Opts#{override_to => local});
|
||||||
remove(Node, KeyPath, Opts) ->
|
remove(Node, KeyPath, Opts) ->
|
||||||
emqx_conf_proto_v1:remove_config(Node, KeyPath, Opts).
|
emqx_conf_proto_v2:remove_config(Node, KeyPath, Opts).
|
||||||
|
|
||||||
%% @doc reset all value of key path in cluster-override.conf or local-override.conf.
|
%% @doc reset all value of key path in cluster-override.conf or local-override.conf.
|
||||||
-spec reset(emqx_map_lib:config_key_path(), emqx_config:update_opts()) ->
|
-spec reset(emqx_map_lib:config_key_path(), emqx_config:update_opts()) ->
|
||||||
{ok, emqx_config:update_result()} | {error, emqx_config:update_error()}.
|
{ok, emqx_config:update_result()} | {error, emqx_config:update_error()}.
|
||||||
reset(KeyPath, Opts) ->
|
reset(KeyPath, Opts) ->
|
||||||
emqx_conf_proto_v1:reset(KeyPath, Opts).
|
emqx_conf_proto_v2:reset(KeyPath, Opts).
|
||||||
|
|
||||||
%% @doc reset the specified node's key path in local-override.conf.
|
%% @doc reset the specified node's key path in local-override.conf.
|
||||||
-spec reset(node(), emqx_map_lib:config_key_path(), emqx_config:update_opts()) ->
|
-spec reset(node(), emqx_map_lib:config_key_path(), emqx_config:update_opts()) ->
|
||||||
|
@ -133,7 +133,7 @@ reset(KeyPath, Opts) ->
|
||||||
reset(Node, KeyPath, Opts) when Node =:= node() ->
|
reset(Node, KeyPath, Opts) when Node =:= node() ->
|
||||||
emqx:reset_config(KeyPath, Opts#{override_to => local});
|
emqx:reset_config(KeyPath, Opts#{override_to => local});
|
||||||
reset(Node, KeyPath, Opts) ->
|
reset(Node, KeyPath, Opts) ->
|
||||||
emqx_conf_proto_v1:reset(Node, KeyPath, Opts).
|
emqx_conf_proto_v2:reset(Node, KeyPath, Opts).
|
||||||
|
|
||||||
%% @doc Called from build script.
|
%% @doc Called from build script.
|
||||||
-spec dump_schema(file:name_all()) -> ok.
|
-spec dump_schema(file:name_all()) -> ok.
|
||||||
|
|
|
@ -97,7 +97,7 @@ copy_override_conf_from_core_node() ->
|
||||||
?SLOG(debug, #{msg => "skip_copy_overide_conf_from_core_node"}),
|
?SLOG(debug, #{msg => "skip_copy_overide_conf_from_core_node"}),
|
||||||
{ok, ?DEFAULT_INIT_TXN_ID};
|
{ok, ?DEFAULT_INIT_TXN_ID};
|
||||||
Nodes ->
|
Nodes ->
|
||||||
{Results, Failed} = emqx_conf_proto_v1:get_override_config_file(Nodes),
|
{Results, Failed} = emqx_conf_proto_v2:get_override_config_file(Nodes),
|
||||||
{Ready, NotReady0} = lists:partition(fun(Res) -> element(1, Res) =:= ok end, Results),
|
{Ready, NotReady0} = lists:partition(fun(Res) -> element(1, Res) =:= ok end, Results),
|
||||||
NotReady = lists:filter(fun(Res) -> element(1, Res) =:= error end, NotReady0),
|
NotReady = lists:filter(fun(Res) -> element(1, Res) =:= error end, NotReady0),
|
||||||
case (Failed =/= [] orelse NotReady =/= []) andalso Ready =/= [] of
|
case (Failed =/= [] orelse NotReady =/= []) andalso Ready =/= [] of
|
||||||
|
|
|
@ -20,7 +20,20 @@
|
||||||
|
|
||||||
-export([
|
-export([
|
||||||
introduced_in/0,
|
introduced_in/0,
|
||||||
sync_data_from_node/1
|
sync_data_from_node/1,
|
||||||
|
get_config/2,
|
||||||
|
get_config/3,
|
||||||
|
get_all/1,
|
||||||
|
|
||||||
|
update/3,
|
||||||
|
update/4,
|
||||||
|
remove_config/2,
|
||||||
|
remove_config/3,
|
||||||
|
|
||||||
|
reset/2,
|
||||||
|
reset/3,
|
||||||
|
|
||||||
|
get_override_config_file/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-include_lib("emqx/include/bpapi.hrl").
|
-include_lib("emqx/include/bpapi.hrl").
|
||||||
|
@ -31,3 +44,66 @@ introduced_in() ->
|
||||||
-spec sync_data_from_node(node()) -> {ok, binary()} | emqx_rpc:badrpc().
|
-spec sync_data_from_node(node()) -> {ok, binary()} | emqx_rpc:badrpc().
|
||||||
sync_data_from_node(Node) ->
|
sync_data_from_node(Node) ->
|
||||||
rpc:call(Node, emqx_conf_app, sync_data_from_node, [], 20000).
|
rpc:call(Node, emqx_conf_app, sync_data_from_node, [], 20000).
|
||||||
|
-type update_config_key_path() :: [emqx_map_lib:config_key(), ...].
|
||||||
|
|
||||||
|
-spec get_config(node(), emqx_map_lib:config_key_path()) ->
|
||||||
|
term() | emqx_rpc:badrpc().
|
||||||
|
get_config(Node, KeyPath) ->
|
||||||
|
rpc:call(Node, emqx, get_config, [KeyPath]).
|
||||||
|
|
||||||
|
-spec get_config(node(), emqx_map_lib:config_key_path(), _Default) ->
|
||||||
|
term() | emqx_rpc:badrpc().
|
||||||
|
get_config(Node, KeyPath, Default) ->
|
||||||
|
rpc:call(Node, emqx, get_config, [KeyPath, Default]).
|
||||||
|
|
||||||
|
-spec get_all(emqx_map_lib:config_key_path()) -> emqx_rpc:multicall_result().
|
||||||
|
get_all(KeyPath) ->
|
||||||
|
rpc:multicall(emqx_conf, get_node_and_config, [KeyPath], 5000).
|
||||||
|
|
||||||
|
-spec update(
|
||||||
|
update_config_key_path(),
|
||||||
|
emqx_config:update_request(),
|
||||||
|
emqx_config:update_opts()
|
||||||
|
) -> {ok, emqx_config:update_result()} | {error, emqx_config:update_error()}.
|
||||||
|
update(KeyPath, UpdateReq, Opts) ->
|
||||||
|
emqx_cluster_rpc:multicall(emqx, update_config, [KeyPath, UpdateReq, Opts]).
|
||||||
|
|
||||||
|
-spec update(
|
||||||
|
node(),
|
||||||
|
update_config_key_path(),
|
||||||
|
emqx_config:update_request(),
|
||||||
|
emqx_config:update_opts()
|
||||||
|
) ->
|
||||||
|
{ok, emqx_config:update_result()}
|
||||||
|
| {error, emqx_config:update_error()}
|
||||||
|
| emqx_rpc:badrpc().
|
||||||
|
update(Node, KeyPath, UpdateReq, Opts) ->
|
||||||
|
rpc:call(Node, emqx, update_config, [KeyPath, UpdateReq, Opts], 5000).
|
||||||
|
|
||||||
|
-spec remove_config(update_config_key_path(), emqx_config:update_opts()) ->
|
||||||
|
{ok, emqx_config:update_result()} | {error, emqx_config:update_error()}.
|
||||||
|
remove_config(KeyPath, Opts) ->
|
||||||
|
emqx_cluster_rpc:multicall(emqx, remove_config, [KeyPath, Opts]).
|
||||||
|
|
||||||
|
-spec remove_config(node(), update_config_key_path(), emqx_config:update_opts()) ->
|
||||||
|
{ok, emqx_config:update_result()}
|
||||||
|
| {error, emqx_config:update_error()}
|
||||||
|
| emqx_rpc:badrpc().
|
||||||
|
remove_config(Node, KeyPath, Opts) ->
|
||||||
|
rpc:call(Node, emqx, remove_config, [KeyPath, Opts], 5000).
|
||||||
|
|
||||||
|
-spec reset(update_config_key_path(), emqx_config:update_opts()) ->
|
||||||
|
{ok, emqx_config:update_result()} | {error, emqx_config:update_error()}.
|
||||||
|
reset(KeyPath, Opts) ->
|
||||||
|
emqx_cluster_rpc:multicall(emqx, reset_config, [KeyPath, Opts]).
|
||||||
|
|
||||||
|
-spec reset(node(), update_config_key_path(), emqx_config:update_opts()) ->
|
||||||
|
{ok, emqx_config:update_result()}
|
||||||
|
| {error, emqx_config:update_error()}
|
||||||
|
| emqx_rpc:badrpc().
|
||||||
|
reset(Node, KeyPath, Opts) ->
|
||||||
|
rpc:call(Node, emqx, reset_config, [KeyPath, Opts]).
|
||||||
|
|
||||||
|
-spec get_override_config_file([node()]) -> emqx_rpc:multicall_result().
|
||||||
|
get_override_config_file(Nodes) ->
|
||||||
|
rpc:multicall(Nodes, emqx_conf_app, get_override_config_file, [], 20000).
|
||||||
|
|
Loading…
Reference in New Issue