Remove the 'emqx_time' module and use 'erlang:system_time/1'

This commit is contained in:
Feng Lee 2019-11-01 08:07:34 +08:00
parent 223163d5b9
commit 605a03453e
3 changed files with 8 additions and 7 deletions

View File

@ -158,7 +158,7 @@ encode_alarm({AlarmId, #alarm{severity = Severity,
{desc, [{severity, Severity},
{title, iolist_to_binary(Title)},
{summary, iolist_to_binary(Summary)},
{timestamp, emqx_time:now_ms(Ts)}]}]);
{timestamp, emqx_misc:now_to_secs(Ts)}]}]);
encode_alarm({AlarmId, undefined}) ->
emqx_json:safe_encode([{id, maybe_to_binary(AlarmId)}]);
encode_alarm({AlarmId, AlarmDesc}) ->

View File

@ -99,7 +99,7 @@ detect(#{clientid := ClientId, peerhost := PeerHost},
%% Create a flapping record.
Flapping = #flapping{clientid = ClientId,
peerhost = PeerHost,
started_at = emqx_time:now_ms(),
started_at = erlang:system_time(millisecond),
detect_cnt = 1
},
true = ets:insert(?FLAPPING_TAB, Flapping),
@ -111,7 +111,7 @@ detect(#{clientid := ClientId, peerhost := PeerHost},
get_policy() ->
emqx:get_env(flapping_detect_policy, ?DEFAULT_DETECT_POLICY).
now_diff(TS) -> emqx_time:now_ms() - TS.
now_diff(TS) -> erlang:system_time(millisecond) - TS.
%%--------------------------------------------------------------------
%% gen_server callbacks
@ -143,7 +143,7 @@ handle_cast({detected, Flapping = #flapping{clientid = ClientId,
[ClientId, esockd_net:ntoa(PeerHost), DetectCnt, Duration]),
%% Banned.
BannedFlapping = Flapping#flapping{clientid = {banned, ClientId},
banned_at = emqx_time:now_ms()
banned_at = erlang:system_time(millisecond)
},
alarm_handler:set_alarm({{flapping_detected, ClientId}, BannedFlapping}),
ets:insert(?FLAPPING_TAB, BannedFlapping);
@ -160,7 +160,8 @@ handle_cast(Msg, State) ->
handle_info({timeout, TRef, expire_flapping}, State = #{tref := TRef}) ->
with_flapping_tab(fun expire_flapping/2,
[emqx_time:now_ms(), get_policy()]),
[erlang:system_time(millisecond),
get_policy()]),
{noreply, ensure_timer(State#{tref => undefined}), hibernate};
handle_info(Info, State) ->

View File

@ -62,7 +62,7 @@ on_client_connected(ClientInfo, ConnAck, ConnInfo, Env) ->
connack => ConnAck,
clean_start => CleanStart,
expiry_interval => ExpiryInterval,
ts => emqx_time:now_ms()
ts => erlang:system_time(millisecond)
},
case emqx_json:safe_encode(Presence) of
{ok, Payload} ->
@ -78,7 +78,7 @@ on_client_disconnected(ClientInfo, Reason, ConnInfo, Env) ->
Presence = #{clientid => ClientId,
username => Username,
reason => reason(Reason),
ts => emqx_time:now_ms()
ts => erlang:system_time(millisecond)
},
case emqx_json:safe_encode(Presence) of
{ok, Payload} ->