perf(config): get_raw with 'binary' root key
This commit is contained in:
parent
ce6343a4f3
commit
77f67a9d07
|
@ -151,7 +151,7 @@ get_root([RootName | _]) ->
|
||||||
%% @doc For the given path, get raw root value enclosed in a single-key map.
|
%% @doc For the given path, get raw root value enclosed in a single-key map.
|
||||||
%% key is ensured to be binary.
|
%% key is ensured to be binary.
|
||||||
get_root_raw([RootName | _]) ->
|
get_root_raw([RootName | _]) ->
|
||||||
#{bin(RootName) => do_get_raw([RootName], #{})}.
|
#{bin(RootName) => get_raw([RootName], #{})}.
|
||||||
|
|
||||||
%% @doc Get a config value for the given path.
|
%% @doc Get a config value for the given path.
|
||||||
%% The path should at least include root config name.
|
%% The path should at least include root config name.
|
||||||
|
@ -288,9 +288,11 @@ get_default_value([RootName | _] = KeyPath) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec get_raw(emqx_utils_maps:config_key_path()) -> term().
|
-spec get_raw(emqx_utils_maps:config_key_path()) -> term().
|
||||||
|
get_raw([Root | T]) when is_atom(Root) -> get_raw([bin(Root) | T]);
|
||||||
get_raw(KeyPath) -> do_get_raw(KeyPath).
|
get_raw(KeyPath) -> do_get_raw(KeyPath).
|
||||||
|
|
||||||
-spec get_raw(emqx_utils_maps:config_key_path(), term()) -> term().
|
-spec get_raw(emqx_utils_maps:config_key_path(), term()) -> term().
|
||||||
|
get_raw([Root | T], Default) when is_atom(Root) -> get_raw([bin(Root) | T], Default);
|
||||||
get_raw(KeyPath, Default) -> do_get_raw(KeyPath, Default).
|
get_raw(KeyPath, Default) -> do_get_raw(KeyPath, Default).
|
||||||
|
|
||||||
-spec put_raw(map()) -> ok.
|
-spec put_raw(map()) -> ok.
|
||||||
|
|
|
@ -177,7 +177,9 @@ t_sub_key_update_remove(_Config) ->
|
||||||
{ok, #{post_config_update => #{emqx_config_handler_SUITE => ok}}},
|
{ok, #{post_config_update => #{emqx_config_handler_SUITE => ok}}},
|
||||||
emqx:remove_config(KeyPath)
|
emqx:remove_config(KeyPath)
|
||||||
),
|
),
|
||||||
?assertError({config_not_found, KeyPath}, emqx:get_raw_config(KeyPath)),
|
?assertError(
|
||||||
|
{config_not_found, [<<"sysmon">>, os, cpu_check_interval]}, emqx:get_raw_config(KeyPath)
|
||||||
|
),
|
||||||
OSKey = maps:keys(emqx:get_raw_config([sysmon, os])),
|
OSKey = maps:keys(emqx:get_raw_config([sysmon, os])),
|
||||||
?assertEqual(false, lists:member(<<"cpu_check_interval">>, OSKey)),
|
?assertEqual(false, lists:member(<<"cpu_check_interval">>, OSKey)),
|
||||||
?assert(length(OSKey) > 0),
|
?assert(length(OSKey) > 0),
|
||||||
|
|
Loading…
Reference in New Issue