Просмотр исходного кода

refactor(config): rename emqx_config:update_config/2 to emqx_config:update/2

Shawn 4 лет назад
Родитель
Сommit
2ddcfdf365

+ 3 - 3
apps/emqx/src/emqx_config.erl

@@ -46,7 +46,7 @@
         , 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
@@ -126,9 +126,9 @@ put(Config) ->
 put(KeyPath, 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()}.
-update_config(ConfKeyPath, UpdateReq) ->
+update(ConfKeyPath, UpdateReq) ->
     emqx_config_handler:update_config(ConfKeyPath, UpdateReq, get_raw()).
 
 -spec get_raw() -> map().

+ 2 - 2
apps/emqx/test/emqx_alarm_SUITE.erl

@@ -28,14 +28,14 @@ all() -> emqx_ct:all(?MODULE).
 init_per_testcase(t_size_limit, Config) ->
     emqx_ct_helpers:boot_modules(all),
     emqx_ct_helpers:start_apps([]),
-    emqx_config:update_config([alarm], #{
+    emqx_config:update([alarm], #{
             <<"size_limit">> => 2
         }),
     Config;
 init_per_testcase(t_validity_period, Config) ->
     emqx_ct_helpers:boot_modules(all),
     emqx_ct_helpers:start_apps([]),
-    emqx_config:update_config([alarm], #{
+    emqx_config:update([alarm], #{
             <<"validity_period">> => <<"1s">>
         }),
     Config;

+ 1 - 1
apps/emqx_authz/src/emqx_authz.erl

@@ -49,7 +49,7 @@ lookup() ->
     emqx_config:get(?CONF_KEY_PATH, []).
 
 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
 handle_update_config({head, Rule}, OldConf) when is_map(Rule), is_list(OldConf) ->

+ 2 - 2
apps/emqx_authz/test/emqx_authz_SUITE.erl

@@ -30,8 +30,8 @@ groups() ->
 
 init_per_suite(Config) ->
     ok = emqx_ct_helpers:start_apps([emqx_authz]),
-    ok = emqx_config:update_config([zones, default, acl, cache, enable], false),
-    ok = emqx_config:update_config([zones, default, acl, enable], true),
+    ok = emqx_config:update([zones, default, acl, cache, enable], false),
+    ok = emqx_config:update([zones, default, acl, enable], true),
     emqx_authz:update(replace, []),
     Config.
 

+ 2 - 2
apps/emqx_authz/test/emqx_authz_http_SUITE.erl

@@ -36,8 +36,8 @@ init_per_suite(Config) ->
     meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
     ok = emqx_ct_helpers:start_apps([emqx_authz]),
-    ok = emqx_config:update_config([zones, default, acl, cache, enable], false),
-    ok = emqx_config:update_config([zones, default, acl, enable], true),
+    ok = emqx_config:update([zones, default, acl, cache, enable], false),
+    ok = emqx_config:update([zones, default, acl, enable], true),
     Rules = [#{ <<"config">> => #{
                     <<"url">> => <<"https://fake.com:443/">>,
                     <<"headers">> => #{},

+ 2 - 2
apps/emqx_authz/test/emqx_authz_mongo_SUITE.erl

@@ -38,8 +38,8 @@ init_per_suite(Config) ->
 
     ok = emqx_ct_helpers:start_apps([emqx_authz]),
     ct:pal("---- emqx_hooks: ~p", [ets:tab2list(emqx_hooks)]),
-    ok = emqx_config:update_config([zones, default, acl, cache, enable], false),
-    ok = emqx_config:update_config([zones, default, acl, enable], true),
+    ok = emqx_config:update([zones, default, acl, cache, enable], false),
+    ok = emqx_config:update([zones, default, acl, enable], true),
     Rules = [#{ <<"config">> => #{
                         <<"mongo_type">> => <<"single">>,
                         <<"server">> => <<"127.0.0.1:27017">>,

+ 2 - 2
apps/emqx_authz/test/emqx_authz_mysql_SUITE.erl

@@ -36,8 +36,8 @@ init_per_suite(Config) ->
     meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
     ok = emqx_ct_helpers:start_apps([emqx_authz]),
-    ok = emqx_config:update_config([zones, default, acl, cache, enable], false),
-    ok = emqx_config:update_config([zones, default, acl, enable], true),
+    ok = emqx_config:update([zones, default, acl, cache, enable], false),
+    ok = emqx_config:update([zones, default, acl, enable], true),
     Rules = [#{ <<"config">> => #{
                     <<"server">> => <<"127.0.0.1:27017">>,
                     <<"pool_size">> => 1,

+ 2 - 2
apps/emqx_authz/test/emqx_authz_pgsql_SUITE.erl

@@ -36,8 +36,8 @@ init_per_suite(Config) ->
     meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
     ok = emqx_ct_helpers:start_apps([emqx_authz]),
-    ok = emqx_config:update_config([zones, default, acl, cache, enable], false),
-    ok = emqx_config:update_config([zones, default, acl, enable], true),
+    ok = emqx_config:update([zones, default, acl, cache, enable], false),
+    ok = emqx_config:update([zones, default, acl, enable], true),
     Rules = [#{ <<"config">> => #{
                     <<"server">> => <<"127.0.0.1:27017">>,
                     <<"pool_size">> => 1,

+ 2 - 2
apps/emqx_authz/test/emqx_authz_redis_SUITE.erl

@@ -36,8 +36,8 @@ init_per_suite(Config) ->
     meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
     meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
     ok = emqx_ct_helpers:start_apps([emqx_authz]),
-    ok = emqx_config:update_config([zones, default, acl, cache, enable], false),
-    ok = emqx_config:update_config([zones, default, acl, enable], true),
+    ok = emqx_config:update([zones, default, acl, cache, enable], false),
+    ok = emqx_config:update([zones, default, acl, enable], true),
     Rules = [#{ <<"config">> => #{
                     <<"server">> => <<"127.0.0.1:27017">>,
                     <<"pool_size">> => 1,

+ 1 - 1
apps/emqx_data_bridge/src/emqx_data_bridge.erl

@@ -60,4 +60,4 @@ config_key_path() ->
     [emqx_data_bridge, bridges].
 
 update_config(ConfigReq) ->
-    emqx_config:update_config(config_key_path(), ConfigReq).
+    emqx_config:update(config_key_path(), ConfigReq).