fix(delayed): fix code style error
This commit is contained in:
parent
eeb92dae23
commit
1a8288de75
|
@ -55,6 +55,7 @@
|
|||
-export([format_delayed/1]).
|
||||
|
||||
-record(delayed_message, {key, delayed, msg}).
|
||||
-type delayed_message() :: #delayed_message{}.
|
||||
|
||||
%% sync ms with record change
|
||||
-define(QUERY_MS(Id), [{{delayed_message, {'_', Id}, '_', '_'}, [], ['$_']}]).
|
||||
|
@ -116,7 +117,7 @@ start_link() ->
|
|||
Opts = emqx_conf:get([delayed], #{}),
|
||||
gen_server:start_link({local, ?SERVER}, ?MODULE, [Opts], []).
|
||||
|
||||
-spec(store(#delayed_message{}) -> ok | {error, atom()}).
|
||||
-spec(store(delayed_message()) -> ok | {error, atom()}).
|
||||
store(DelayedMsg) ->
|
||||
gen_server:call(?SERVER, {store, DelayedMsg}, infinity).
|
||||
|
||||
|
@ -273,14 +274,15 @@ handle_info({timeout, TRef, do_publish}, State = #{timer := TRef}) ->
|
|||
{noreply, ensure_publish_timer(State#{timer := undefined, publish_at := 0})};
|
||||
|
||||
handle_info(stats, State = #{stats_fun := StatsFun}) ->
|
||||
StatsTimer = erlang:send_after(timer:seconds(1), self(), stats),
|
||||
StatsFun(delayed_count()),
|
||||
{noreply, State, hibernate};
|
||||
{noreply, State#{stats_timer := StatsTimer}, hibernate};
|
||||
|
||||
handle_info(Info, State) ->
|
||||
?SLOG(error, #{msg => "unexpected_info", info => Info}),
|
||||
{noreply, State}.
|
||||
|
||||
terminate(_Reason, #{timer := TRef}) ->
|
||||
terminate(_Reason, #{stats_timer := TRef}) ->
|
||||
emqx_conf:remove_handler([delayed]),
|
||||
emqx_misc:cancel_timer(TRef).
|
||||
|
||||
|
@ -294,7 +296,7 @@ code_change(_Vsn, State, _Extra) ->
|
|||
%% Ensure the stats
|
||||
ensure_stats_event(State) ->
|
||||
StatsFun = emqx_stats:statsfun('delayed.count', 'delayed.max'),
|
||||
{ok, StatsTimer} = timer:send_interval(timer:seconds(1), stats),
|
||||
StatsTimer = erlang:send_after(timer:seconds(1), self(), stats),
|
||||
State#{stats_fun => StatsFun, stats_timer => StatsTimer}.
|
||||
|
||||
%% Ensure publish timer
|
||||
|
|
Loading…
Reference in New Issue