fix(emqx_config): correct some function sepcs and return values

This commit is contained in:
Shawn 2021-08-12 15:49:47 +08:00
parent b652a64dbb
commit cc1222ffea
1 changed files with 6 additions and 6 deletions

View File

@ -177,7 +177,7 @@ find_listener_conf(Zone, Listener, KeyPath) ->
put(Config) -> put(Config) ->
maps:fold(fun(RootName, RootValue, _) -> maps:fold(fun(RootName, RootValue, _) ->
?MODULE:put([RootName], RootValue) ?MODULE:put([RootName], RootValue)
end, [], Config). end, ok, Config).
-spec put(emqx_map_lib:config_key_path(), term()) -> ok. -spec put(emqx_map_lib:config_key_path(), term()) -> ok.
put(KeyPath, Config) -> do_put(?CONF, KeyPath, Config). put(KeyPath, Config) -> do_put(?CONF, KeyPath, Config).
@ -209,7 +209,7 @@ reset([RootName | _] = KeyPath) ->
Error Error
end. end.
-spec get_default_value(emqx_map_lib:config_key_path()) -> ok | {error, term()}. -spec get_default_value(emqx_map_lib:config_key_path()) -> {ok, term()} | {error, term()}.
get_default_value([RootName | _] = KeyPath) -> get_default_value([RootName | _] = KeyPath) ->
BinKeyPath = [bin(Key) || Key <- KeyPath], BinKeyPath = [bin(Key) || Key <- KeyPath],
case find_raw([RootName]) of case find_raw([RootName]) of
@ -236,7 +236,7 @@ get_raw(KeyPath, Default) -> do_get(?RAW_CONF, KeyPath, Default).
put_raw(Config) -> put_raw(Config) ->
maps:fold(fun(RootName, RootV, _) -> maps:fold(fun(RootName, RootV, _) ->
?MODULE:put_raw([RootName], RootV) ?MODULE:put_raw([RootName], RootV)
end, [], hocon_schema:get_value([], Config)). end, ok, hocon_schema:get_value([], Config)).
-spec put_raw(emqx_map_lib:config_key_path(), term()) -> ok. -spec put_raw(emqx_map_lib:config_key_path(), term()) -> ok.
put_raw(KeyPath, Config) -> do_put(?RAW_CONF, KeyPath, Config). put_raw(KeyPath, Config) -> do_put(?RAW_CONF, KeyPath, Config).
@ -321,7 +321,7 @@ save_schema_mod(SchemaMod) ->
get_schema_mod() -> get_schema_mod() ->
persistent_term:get(?PERSIS_MOD_ROOTNAMES, #{}). persistent_term:get(?PERSIS_MOD_ROOTNAMES, #{}).
-spec get_schema_mod(atom() | binary()) -> [module()]. -spec get_schema_mod(atom() | binary()) -> module().
get_schema_mod(RootName) -> get_schema_mod(RootName) ->
maps:get(bin(RootName), get_schema_mod()). maps:get(bin(RootName), get_schema_mod()).