fix: elvis warning

This commit is contained in:
Zhongwen Deng 2022-03-09 20:38:42 +08:00
parent 7beaa91814
commit 3aa7c3a8dd
2 changed files with 28 additions and 26 deletions

View File

@ -256,14 +256,15 @@ typename_to_spec("percent()", _Mod) -> #{type => percent};
typename_to_spec("file()", _Mod) -> #{type => string}; typename_to_spec("file()", _Mod) -> #{type => string};
typename_to_spec("ip_port()", _Mod) -> #{type => ip_port}; typename_to_spec("ip_port()", _Mod) -> #{type => ip_port};
typename_to_spec("url()", _Mod) -> #{type => url}; typename_to_spec("url()", _Mod) -> #{type => url};
typename_to_spec("bytesize()", _Mod) -> #{type => byteSize}; typename_to_spec("bytesize()", _Mod) -> #{type => 'byteSize'};
typename_to_spec("wordsize()", _Mod) -> #{type => byteSize}; typename_to_spec("wordsize()", _Mod) -> #{type => 'byteSize'};
typename_to_spec("qos()", _Mod) -> #{type => enum, symbols => [0, 1, 2]}; typename_to_spec("qos()", _Mod) -> #{type => enum, symbols => [0, 1, 2]};
typename_to_spec("comma_separated_list()", _Mod) -> #{type => comma_separated_string}; typename_to_spec("comma_separated_list()", _Mod) -> #{type => comma_separated_string};
typename_to_spec("comma_separated_atoms()", _Mod) -> #{type => comma_separated_string}; typename_to_spec("comma_separated_atoms()", _Mod) -> #{type => comma_separated_string};
typename_to_spec("pool_type()", _Mod) -> #{type => enum, symbols => [random, hash]}; typename_to_spec("pool_type()", _Mod) -> #{type => enum, symbols => [random, hash]};
typename_to_spec("log_level()", _Mod) -> typename_to_spec("log_level()", _Mod) ->
#{type => enum, symbols => [debug, info, notice, warning, error, critical, alert, emergency, all]}; #{type => enum, symbols => [debug, info, notice, warning, error,
critical, alert, emergency, all]};
typename_to_spec("rate()", _Mod) -> #{type => string}; typename_to_spec("rate()", _Mod) -> #{type => string};
typename_to_spec("capacity()", _Mod) -> #{type => string}; typename_to_spec("capacity()", _Mod) -> #{type => string};
typename_to_spec("burst_rate()", _Mod) -> #{type => string}; typename_to_spec("burst_rate()", _Mod) -> #{type => string};

View File

@ -61,37 +61,38 @@ copy_override_conf_from_core_node() ->
nodes => Nodes, failed => Failed, not_ready => NotReady}), nodes => Nodes, failed => Failed, not_ready => NotReady}),
{error, "core node not ready"}; {error, "core node not ready"};
_ -> _ ->
SortFun = fun({ok, #{wall_clock := W1}}, {ok, #{wall_clock := W2}}) -> W1 > W2 end, SortFun = fun({ok, #{wall_clock := W1}},
{ok, #{wall_clock := W2}}) -> W1 > W2 end,
[{ok, Info} | _] = lists:sort(SortFun, Ready), [{ok, Info} | _] = lists:sort(SortFun, Ready),
#{node := Node, conf := RawOverrideConf, tnx_id := TnxId} = Info, #{node := Node, conf := RawOverrideConf, tnx_id := TnxId} = Info,
?SLOG(debug, #{msg => "copy_overide_conf_from_core_node_success", node => Node}), Msg = #{msg => "copy_overide_conf_from_core_node_success", node => Node},
ok = emqx_config:save_to_override_conf(RawOverrideConf, #{override_to => cluster}), ?SLOG(debug, Msg),
ok = emqx_config:save_to_override_conf(RawOverrideConf,
#{override_to => cluster}),
{ok, TnxId} {ok, TnxId}
end end
end. end.
get_override_config_file() -> get_override_config_file() ->
Node = node(), Node = node(),
Role = mria_rlog:role(),
case emqx_app:get_init_config_load_done() of case emqx_app:get_init_config_load_done() of
false -> {error, #{node => Node, msg => "init_conf_load_not_done"}}; false -> {error, #{node => Node, msg => "init_conf_load_not_done"}};
true -> true when Role =:= core ->
case mria_rlog:role() of case erlang:whereis(emqx_config_handler) of
core -> undefined -> {error, #{node => Node, msg => "emqx_config_handler_not_ready"}};
case erlang:whereis(emqx_config_handler) of _ ->
undefined -> {error, #{node => Node, msg => "emqx_config_handler_not_ready"}}; Fun = fun() ->
_ -> TnxId = emqx_cluster_rpc:get_node_tnx_id(Node),
Fun = fun() -> WallClock = erlang:statistics(wall_clock),
TnxId = emqx_cluster_rpc:get_node_tnx_id(Node), Conf = emqx_config_handler:get_raw_cluster_override_conf(),
WallClock = erlang:statistics(wall_clock), #{wall_clock => WallClock, conf => Conf, tnx_id => TnxId, node => Node}
Conf = emqx_config_handler:get_raw_cluster_override_conf(), end,
#{wall_clock => WallClock, conf => Conf, tnx_id => TnxId, node => Node} case mria:ro_transaction(?CLUSTER_RPC_SHARD, Fun) of
end, {atomic, Res} -> {ok, Res};
case mria:ro_transaction(?CLUSTER_RPC_SHARD, Fun) of {aborted, Reason} -> {error, #{node => Node, msg => Reason}}
{atomic, Res} -> {ok, Res}; end
{aborted, Reason} -> {error, #{node => Node, msg => Reason}} end;
end true when Role =:= replicant ->
end; {ignore, #{node => Node}}
replicant ->
{ignore, #{node => Node}}
end
end. end.