fix(emqx_config): always return atom-key map for emqx_config:get/2

This commit is contained in:
Shawn 2021-08-09 13:35:02 +08:00
parent eee98a5803
commit bafcb7f34a
1 changed files with 6 additions and 1 deletions

View File

@ -302,7 +302,7 @@ do_get(Type, KeyPath) ->
do_get(Type, [], Default) -> do_get(Type, [], Default) ->
AllConf = lists:foldl(fun AllConf = lists:foldl(fun
({?PERSIS_KEY(Type0, RootName), Conf}, AccIn) when Type0 == Type -> ({?PERSIS_KEY(Type0, RootName), Conf}, AccIn) when Type0 == Type ->
AccIn#{RootName => Conf}; AccIn#{conf_key(Type0, RootName) => Conf};
(_, AccIn) -> AccIn (_, AccIn) -> AccIn
end, #{}, persistent_term:get()), end, #{}, persistent_term:get()),
case map_size(AllConf) == 0 of case map_size(AllConf) == 0 of
@ -343,3 +343,8 @@ atom(Atom) when is_atom(Atom) ->
bin(Bin) when is_binary(Bin) -> Bin; bin(Bin) when is_binary(Bin) -> Bin;
bin(Atom) when is_atom(Atom) -> atom_to_binary(Atom, utf8). bin(Atom) when is_atom(Atom) -> atom_to_binary(Atom, utf8).
conf_key(?CONF, RootName) ->
atom(RootName);
conf_key(?RAW_CONF, RootName) ->
bin(RootName).