Skip to content

Commit

Permalink
fix: elvis warning
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwencool committed Mar 9, 2022
1 parent 7beaa91 commit 3aa7c3a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
7 changes: 4 additions & 3 deletions apps/emqx_conf/src/emqx_conf.erl
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,15 @@ typename_to_spec("percent()", _Mod) -> #{type => percent};
typename_to_spec("file()", _Mod) -> #{type => string};
typename_to_spec("ip_port()", _Mod) -> #{type => ip_port};
typename_to_spec("url()", _Mod) -> #{type => url};
typename_to_spec("bytesize()", _Mod) -> #{type => byteSize};
typename_to_spec("wordsize()", _Mod) -> #{type => byteSize};
typename_to_spec("bytesize()", _Mod) -> #{type => 'byteSize'};
typename_to_spec("wordsize()", _Mod) -> #{type => 'byteSize'};
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_atoms()", _Mod) -> #{type => comma_separated_string};
typename_to_spec("pool_type()", _Mod) -> #{type => enum, symbols => [random, hash]};
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("capacity()", _Mod) -> #{type => string};
typename_to_spec("burst_rate()", _Mod) -> #{type => string};
Expand Down
47 changes: 24 additions & 23 deletions apps/emqx_conf/src/emqx_conf_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,37 +61,38 @@ copy_override_conf_from_core_node() ->
nodes => Nodes, failed => Failed, not_ready => NotReady}),
{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),
#{node := Node, conf := RawOverrideConf, tnx_id := TnxId} = Info,
?SLOG(debug, #{msg => "copy_overide_conf_from_core_node_success", node => Node}),
ok = emqx_config:save_to_override_conf(RawOverrideConf, #{override_to => cluster}),
Msg = #{msg => "copy_overide_conf_from_core_node_success", node => Node},
?SLOG(debug, Msg),
ok = emqx_config:save_to_override_conf(RawOverrideConf,
#{override_to => cluster}),
{ok, TnxId}
end
end.

get_override_config_file() ->
Node = node(),
Role = mria_rlog:role(),
case emqx_app:get_init_config_load_done() of
false -> {error, #{node => Node, msg => "init_conf_load_not_done"}};
true ->
case mria_rlog:role() of
core ->
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),
WallClock = erlang:statistics(wall_clock),
Conf = emqx_config_handler:get_raw_cluster_override_conf(),
#{wall_clock => WallClock, conf => Conf, tnx_id => TnxId, node => Node}
end,
case mria:ro_transaction(?CLUSTER_RPC_SHARD, Fun) of
{atomic, Res} -> {ok, Res};
{aborted, Reason} -> {error, #{node => Node, msg => Reason}}
end
end;
replicant ->
{ignore, #{node => Node}}
end
true when Role =:= core ->
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),
WallClock = erlang:statistics(wall_clock),
Conf = emqx_config_handler:get_raw_cluster_override_conf(),
#{wall_clock => WallClock, conf => Conf, tnx_id => TnxId, node => Node}
end,
case mria:ro_transaction(?CLUSTER_RPC_SHARD, Fun) of
{atomic, Res} -> {ok, Res};
{aborted, Reason} -> {error, #{node => Node, msg => Reason}}
end
end;
true when Role =:= replicant ->
{ignore, #{node => Node}}
end.

0 comments on commit 3aa7c3a

Please sign in to comment.