refactor(config): rename emqx_config:update_config/2 to emqx_config:update/2
This commit is contained in:
parent
419036bd9a
commit
2ddcfdf365
|
@ -46,7 +46,7 @@
|
||||||
, find_listener_conf/3
|
, find_listener_conf/3
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-export([ update_config/2
|
-export([ update/2
|
||||||
]).
|
]).
|
||||||
|
|
||||||
%% raw configs is the config that is now parsed and tranlated by hocon schema
|
%% raw configs is the config that is now parsed and tranlated by hocon schema
|
||||||
|
@ -126,9 +126,9 @@ put(Config) ->
|
||||||
put(KeyPath, Config) ->
|
put(KeyPath, Config) ->
|
||||||
put(emqx_map_lib:deep_put(KeyPath, get(), Config)).
|
put(emqx_map_lib:deep_put(KeyPath, get(), Config)).
|
||||||
|
|
||||||
-spec update_config(emqx_map_lib:config_key_path(), update_request()) ->
|
-spec update(emqx_map_lib:config_key_path(), update_request()) ->
|
||||||
ok | {error, term()}.
|
ok | {error, term()}.
|
||||||
update_config(ConfKeyPath, UpdateReq) ->
|
update(ConfKeyPath, UpdateReq) ->
|
||||||
emqx_config_handler:update_config(ConfKeyPath, UpdateReq, get_raw()).
|
emqx_config_handler:update_config(ConfKeyPath, UpdateReq, get_raw()).
|
||||||
|
|
||||||
-spec get_raw() -> map().
|
-spec get_raw() -> map().
|
||||||
|
|
|
@ -28,14 +28,14 @@ all() -> emqx_ct:all(?MODULE).
|
||||||
init_per_testcase(t_size_limit, Config) ->
|
init_per_testcase(t_size_limit, Config) ->
|
||||||
emqx_ct_helpers:boot_modules(all),
|
emqx_ct_helpers:boot_modules(all),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
emqx_config:update_config([alarm], #{
|
emqx_config:update([alarm], #{
|
||||||
<<"size_limit">> => 2
|
<<"size_limit">> => 2
|
||||||
}),
|
}),
|
||||||
Config;
|
Config;
|
||||||
init_per_testcase(t_validity_period, Config) ->
|
init_per_testcase(t_validity_period, Config) ->
|
||||||
emqx_ct_helpers:boot_modules(all),
|
emqx_ct_helpers:boot_modules(all),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
emqx_config:update_config([alarm], #{
|
emqx_config:update([alarm], #{
|
||||||
<<"validity_period">> => <<"1s">>
|
<<"validity_period">> => <<"1s">>
|
||||||
}),
|
}),
|
||||||
Config;
|
Config;
|
||||||
|
|
|
@ -49,7 +49,7 @@ lookup() ->
|
||||||
emqx_config:get(?CONF_KEY_PATH, []).
|
emqx_config:get(?CONF_KEY_PATH, []).
|
||||||
|
|
||||||
update(Cmd, Rules) ->
|
update(Cmd, Rules) ->
|
||||||
emqx_config:update_config(?CONF_KEY_PATH, {Cmd, Rules}).
|
emqx_config:update(?CONF_KEY_PATH, {Cmd, Rules}).
|
||||||
|
|
||||||
%% For now we only support re-creating the entire rule list
|
%% For now we only support re-creating the entire rule list
|
||||||
handle_update_config({head, Rule}, OldConf) when is_map(Rule), is_list(OldConf) ->
|
handle_update_config({head, Rule}, OldConf) when is_map(Rule), is_list(OldConf) ->
|
||||||
|
|
|
@ -30,8 +30,8 @@ groups() ->
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||||
ok = emqx_config:update_config([zones, default, acl, cache, enable], false),
|
ok = emqx_config:update([zones, default, acl, cache, enable], false),
|
||||||
ok = emqx_config:update_config([zones, default, acl, enable], true),
|
ok = emqx_config:update([zones, default, acl, enable], true),
|
||||||
emqx_authz:update(replace, []),
|
emqx_authz:update(replace, []),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ init_per_suite(Config) ->
|
||||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||||
ok = emqx_config:update_config([zones, default, acl, cache, enable], false),
|
ok = emqx_config:update([zones, default, acl, cache, enable], false),
|
||||||
ok = emqx_config:update_config([zones, default, acl, enable], true),
|
ok = emqx_config:update([zones, default, acl, enable], true),
|
||||||
Rules = [#{ <<"config">> => #{
|
Rules = [#{ <<"config">> => #{
|
||||||
<<"url">> => <<"https://fake.com:443/">>,
|
<<"url">> => <<"https://fake.com:443/">>,
|
||||||
<<"headers">> => #{},
|
<<"headers">> => #{},
|
||||||
|
|
|
@ -38,8 +38,8 @@ init_per_suite(Config) ->
|
||||||
|
|
||||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||||
ct:pal("---- emqx_hooks: ~p", [ets:tab2list(emqx_hooks)]),
|
ct:pal("---- emqx_hooks: ~p", [ets:tab2list(emqx_hooks)]),
|
||||||
ok = emqx_config:update_config([zones, default, acl, cache, enable], false),
|
ok = emqx_config:update([zones, default, acl, cache, enable], false),
|
||||||
ok = emqx_config:update_config([zones, default, acl, enable], true),
|
ok = emqx_config:update([zones, default, acl, enable], true),
|
||||||
Rules = [#{ <<"config">> => #{
|
Rules = [#{ <<"config">> => #{
|
||||||
<<"mongo_type">> => <<"single">>,
|
<<"mongo_type">> => <<"single">>,
|
||||||
<<"server">> => <<"127.0.0.1:27017">>,
|
<<"server">> => <<"127.0.0.1:27017">>,
|
||||||
|
|
|
@ -36,8 +36,8 @@ init_per_suite(Config) ->
|
||||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||||
ok = emqx_config:update_config([zones, default, acl, cache, enable], false),
|
ok = emqx_config:update([zones, default, acl, cache, enable], false),
|
||||||
ok = emqx_config:update_config([zones, default, acl, enable], true),
|
ok = emqx_config:update([zones, default, acl, enable], true),
|
||||||
Rules = [#{ <<"config">> => #{
|
Rules = [#{ <<"config">> => #{
|
||||||
<<"server">> => <<"127.0.0.1:27017">>,
|
<<"server">> => <<"127.0.0.1:27017">>,
|
||||||
<<"pool_size">> => 1,
|
<<"pool_size">> => 1,
|
||||||
|
|
|
@ -36,8 +36,8 @@ init_per_suite(Config) ->
|
||||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||||
ok = emqx_config:update_config([zones, default, acl, cache, enable], false),
|
ok = emqx_config:update([zones, default, acl, cache, enable], false),
|
||||||
ok = emqx_config:update_config([zones, default, acl, enable], true),
|
ok = emqx_config:update([zones, default, acl, enable], true),
|
||||||
Rules = [#{ <<"config">> => #{
|
Rules = [#{ <<"config">> => #{
|
||||||
<<"server">> => <<"127.0.0.1:27017">>,
|
<<"server">> => <<"127.0.0.1:27017">>,
|
||||||
<<"pool_size">> => 1,
|
<<"pool_size">> => 1,
|
||||||
|
|
|
@ -36,8 +36,8 @@ init_per_suite(Config) ->
|
||||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||||
ok = emqx_config:update_config([zones, default, acl, cache, enable], false),
|
ok = emqx_config:update([zones, default, acl, cache, enable], false),
|
||||||
ok = emqx_config:update_config([zones, default, acl, enable], true),
|
ok = emqx_config:update([zones, default, acl, enable], true),
|
||||||
Rules = [#{ <<"config">> => #{
|
Rules = [#{ <<"config">> => #{
|
||||||
<<"server">> => <<"127.0.0.1:27017">>,
|
<<"server">> => <<"127.0.0.1:27017">>,
|
||||||
<<"pool_size">> => 1,
|
<<"pool_size">> => 1,
|
||||||
|
|
|
@ -60,4 +60,4 @@ config_key_path() ->
|
||||||
[emqx_data_bridge, bridges].
|
[emqx_data_bridge, bridges].
|
||||||
|
|
||||||
update_config(ConfigReq) ->
|
update_config(ConfigReq) ->
|
||||||
emqx_config:update_config(config_key_path(), ConfigReq).
|
emqx_config:update(config_key_path(), ConfigReq).
|
||||||
|
|
Loading…
Reference in New Issue