chore: format emqx apps

This commit is contained in:
JianBo He 2022-04-21 21:34:21 +08:00
parent d6a9072bb0
commit ae1b435ace
4 changed files with 22 additions and 14 deletions

View File

@ -128,7 +128,7 @@ roots(high) ->
{"mqtt",
sc(
ref("mqtt"),
#{ desc => ?DESC(mqtt)}
#{desc => ?DESC(mqtt)}
)},
{?EMQX_AUTHENTICATION_CONFIG_ROOT_NAME,
authentication(
@ -1268,7 +1268,7 @@ fields("sys_topics") ->
{"sys_event_messages",
sc(
ref("event_names"),
#{ desc => ?DESC(sys_event_messages) }
#{desc => ?DESC(sys_event_messages)}
)}
];
fields("event_names") ->

View File

@ -322,7 +322,8 @@ delete_old_file(_New, Old) ->
case is_generated_file(Old) andalso filelib:is_regular(Old) andalso file:delete(Old) of
ok ->
ok;
false -> %% the file is not generated by us, or it is already deleted
%% the file is not generated by us, or it is already deleted
false ->
ok;
{error, Reason} ->
?SLOG(error, #{msg => "failed_to_delete_ssl_file", file_path => Old, reason => Reason})
@ -412,16 +413,21 @@ pem_dir(Dir) ->
filename:join([emqx:mutable_certs_dir(), Dir]).
is_hex_str(HexStr) ->
try is_hex_str2(ensure_str(HexStr))
catch throw: not_hex -> false
try
is_hex_str2(ensure_str(HexStr))
catch
throw:not_hex -> false
end.
is_hex_str2(HexStr) ->
_ = [case S of
_ = [
case S of
S when S >= $0, S =< $9 -> S;
S when S >= $a, S =< $f -> S;
_ -> throw(not_hex)
end || S <- HexStr],
end
|| S <- HexStr
],
true.
hex_str(Bin) ->
@ -457,8 +463,7 @@ do_drop_invalid_certs([Key | Keys], SSL) ->
PemOrPath ->
case is_pem(PemOrPath) orelse is_valid_pem_file(PemOrPath) of
true -> do_drop_invalid_certs(Keys, SSL);
{error, _} ->
do_drop_invalid_certs(Keys, maps:without([Key], SSL))
{error, _} -> do_drop_invalid_certs(Keys, maps:without([Key], SSL))
end
end.

View File

@ -488,7 +488,8 @@ is_tcp_server_available(Host, Port, Timeout) ->
start_ekka() ->
try mnesia_hook:module_info() of
_ -> ekka:start()
catch _:_ ->
catch
_:_ ->
%% Falling back to using Mnesia DB backend.
application:set_env(mria, db_backend, mnesia),
ekka:start()

View File

@ -223,7 +223,9 @@ t_callback_crash(_Config) ->
Opts = #{rawconf_with_defaults => true},
ok = emqx_config_handler:add_handler(CrashPath, ?MODULE),
Old = emqx:get_raw_config(CrashPath),
?assertMatch({error, {config_update_crashed, _}}, emqx:update_config(CrashPath, <<"89%">>, Opts)),
?assertMatch(
{error, {config_update_crashed, _}}, emqx:update_config(CrashPath, <<"89%">>, Opts)
),
New = emqx:get_raw_config(CrashPath),
?assertEqual(Old, New),
ok = emqx_config_handler:remove_handler(CrashPath),