fix(emqx_auth_sys, emqx_ws_connection): Dialyzer warnings

This commit is contained in:
ayodele.akingbule 2020-11-17 10:16:32 +01:00 committed by Zaiming Shi
parent 9db6b3b430
commit 62e0a21ad0
2 changed files with 24 additions and 17 deletions

View File

@ -151,16 +151,16 @@ handle_cast(Msg, State) ->
{noreply, State}. {noreply, State}.
handle_info({timeout, TRef, heartbeat}, State = #state{heartbeat = TRef}) -> handle_info({timeout, TRef, heartbeat}, State = #state{heartbeat = TRef}) ->
_ = publish(uptime, iolist_to_binary(uptime(State))), publish_any(uptime, iolist_to_binary(uptime(State))),
_ = publish(datetime, iolist_to_binary(datetime())), publish_any(datetime, iolist_to_binary(datetime())),
{noreply, heartbeat(State)}; {noreply, heartbeat(State)};
handle_info({timeout, TRef, tick}, State = #state{ticker = TRef, version = Version, sysdescr = Descr}) -> handle_info({timeout, TRef, tick}, State = #state{ticker = TRef, version = Version, sysdescr = Descr}) ->
_ = publish(version, Version), publish_any(version, Version),
_ = publish(sysdescr, Descr), publish_any(sysdescr, Descr),
_ = publish(brokers, ekka_mnesia:running_nodes()), publish_any(brokers, ekka_mnesia:running_nodes()),
_ = publish(stats, emqx_stats:getstats()), publish_any(stats, emqx_stats:getstats()),
_ = publish(metrics, emqx_metrics:all()), publish_any(metrics, emqx_metrics:all()),
{noreply, tick(State), hibernate}; {noreply, tick(State), hibernate};
handle_info(Info, State) -> handle_info(Info, State) ->
@ -192,6 +192,10 @@ uptime(hours, H) ->
uptime(days, D) -> uptime(days, D) ->
[integer_to_list(D), " days, "]. [integer_to_list(D), " days, "].
publish_any(Name, Value) ->
_ = publish(Name, Value),
ok.
publish(uptime, Uptime) -> publish(uptime, Uptime) ->
safe_publish(systop(uptime), Uptime); safe_publish(systop(uptime), Uptime);
publish(datetime, Datetime) -> publish(datetime, Datetime) ->

View File

@ -568,16 +568,16 @@ serialize_and_inc_stats_fun(#state{serialize = Serialize}) ->
]}). ]}).
inc_recv_stats(Cnt, Oct) -> inc_recv_stats(Cnt, Oct) ->
_ = emqx_pd:inc_counter(incoming_bytes, Oct), inc_counter(incoming_bytes, Oct),
_ = emqx_pd:inc_counter(recv_cnt, Cnt), inc_counter(recv_cnt, Cnt),
_ = emqx_pd:inc_counter(recv_oct, Oct), inc_counter(recv_oct, Oct),
emqx_metrics:inc('bytes.received', Oct). emqx_metrics:inc('bytes.received', Oct).
inc_incoming_stats(Packet = ?PACKET(Type)) -> inc_incoming_stats(Packet = ?PACKET(Type)) ->
_ = emqx_pd:inc_counter(recv_pkt, 1), _ = emqx_pd:inc_counter(recv_pkt, 1),
if Type == ?PUBLISH -> if Type == ?PUBLISH ->
_ = emqx_pd:inc_counter(recv_msg, 1), inc_counter(recv_msg, 1),
_ = emqx_pd:inc_counter(incoming_pubs, 1); inc_counter(incoming_pubs, 1);
true -> ok true -> ok
end, end,
emqx_metrics:inc_recv(Packet). emqx_metrics:inc_recv(Packet).
@ -585,18 +585,21 @@ inc_incoming_stats(Packet = ?PACKET(Type)) ->
inc_outgoing_stats(Packet = ?PACKET(Type)) -> inc_outgoing_stats(Packet = ?PACKET(Type)) ->
_ = emqx_pd:inc_counter(send_pkt, 1), _ = emqx_pd:inc_counter(send_pkt, 1),
if Type == ?PUBLISH -> if Type == ?PUBLISH ->
_ = emqx_pd:inc_counter(send_msg, 1), inc_counter(send_msg, 1),
_ = emqx_pd:inc_counter(outgoing_pubs, 1); inc_counter(outgoing_pubs, 1);
true -> ok true -> ok
end, end,
emqx_metrics:inc_sent(Packet). emqx_metrics:inc_sent(Packet).
inc_sent_stats(Cnt, Oct) -> inc_sent_stats(Cnt, Oct) ->
_ = emqx_pd:inc_counter(outgoing_bytes, Oct), inc_counter(outgoing_bytes, Oct),
_ = emqx_pd:inc_counter(send_cnt, Cnt), inc_counter(send_cnt, Cnt),
_ = emqx_pd:inc_counter(send_oct, Oct), inc_counter(send_oct, Oct),
emqx_metrics:inc('bytes.sent', Oct). emqx_metrics:inc('bytes.sent', Oct).
inc_counter(Name, Value) ->
_ = emqx_pd:inc_counter(Name, Value),
ok.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Helper functions %% Helper functions
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------