refactor(emqx_schema): Code style
This commit is contained in:
parent
deccba3406
commit
c9a59968ef
|
@ -741,22 +741,10 @@ sort_log_levels(Levels) ->
|
|||
%% utils
|
||||
-spec(conf_get(string() | [string()], hocon:config()) -> term()).
|
||||
conf_get(Key, Conf) ->
|
||||
V = hocon_schema:get_value(Key, Conf),
|
||||
case is_binary(V) of
|
||||
true ->
|
||||
binary_to_list(V);
|
||||
false ->
|
||||
V
|
||||
end.
|
||||
ensure_list(hocon_schema:get_value(Key, Conf)).
|
||||
|
||||
conf_get(Key, Conf, Default) ->
|
||||
V = hocon_schema:get_value(Key, Conf, Default),
|
||||
case is_binary(V) of
|
||||
true ->
|
||||
binary_to_list(V);
|
||||
false ->
|
||||
V
|
||||
end.
|
||||
ensure_list(hocon_schema:get_value(Key, Conf, Default)).
|
||||
|
||||
filter(Opts) ->
|
||||
[{K, V} || {K, V} <- Opts, V =/= undefined].
|
||||
|
@ -812,5 +800,14 @@ to_atom(Str) when is_list(Str) ->
|
|||
to_atom(Bin) when is_binary(Bin) ->
|
||||
binary_to_atom(Bin, utf8).
|
||||
|
||||
-spec ensure_list(binary() | list(char())) -> list(char()).
|
||||
ensure_list(V) ->
|
||||
case is_binary(V) of
|
||||
true ->
|
||||
binary_to_list(V);
|
||||
false ->
|
||||
V
|
||||
end.
|
||||
|
||||
roots(Module) ->
|
||||
lists:map(fun({_BinName, Root}) -> Root end, hocon_schema:roots(Module)).
|
||||
|
|
Loading…
Reference in New Issue