mirror of
https://github.com/valitydev/how_are_you.git
synced 2024-11-06 02:35:16 +00:00
Listen to self send message for update
This commit is contained in:
parent
27424a2c45
commit
b9af9a70e8
@ -75,7 +75,7 @@ handle_cast(_Msg, State) ->
|
||||
|
||||
-spec handle_info(term(), state()) -> {noreply, state(), hibernate}.
|
||||
|
||||
handle_info(timeout, State0) ->
|
||||
handle_info({timeout, TRef, update}, State0 = #state{timer = TRef}) ->
|
||||
%% TODO add some sort of monitoring
|
||||
%% to prevent metrics overloading entire system
|
||||
#state{handler = Handler, handler_state = HandlerState} = State = restart_timer(State0),
|
||||
@ -121,4 +121,4 @@ restart_timer(State = #state{timer = TimerRef}) ->
|
||||
|
||||
start_timer(State = #state{timer = undefined, handler = Handler, handler_state = HandlerState}) ->
|
||||
Interval = Handler:get_interval(HandlerState),
|
||||
State#state{timer = erlang:send_after(Interval, self(), timeout)}.
|
||||
State#state{timer = erlang:start_timer(Interval, self(), update)}.
|
||||
|
@ -81,7 +81,7 @@ handle_cast(_Msg, State) ->
|
||||
|
||||
-spec handle_info(term(), state()) -> {noreply, state(), hibernate}.
|
||||
|
||||
handle_info(timeout, State0) ->
|
||||
handle_info({timeout, TRef, publish}, State0 = #state{timer = TRef}) ->
|
||||
%% TODO add some sort of monitoring
|
||||
%% to prevent metrics overloading entire system
|
||||
#state{handler = Handler, handler_state = HandlerState} = State = restart_timer(State0),
|
||||
@ -110,4 +110,4 @@ restart_timer(State = #state{timer = TimerRef}) ->
|
||||
|
||||
start_timer(State = #state{timer = undefined, handler = Handler, handler_state = HandlerState}) ->
|
||||
Interval = Handler:get_interval(HandlerState),
|
||||
State#state{timer = erlang:send_after(Interval, self(), timeout)}.
|
||||
State#state{timer = erlang:start_timer(Interval, self(), publish)}.
|
||||
|
Loading…
Reference in New Issue
Block a user