Merge pull request #627 from callbay/master

optimize the procedures that retrieve the Broker version and Borker description in the tick timer
This commit is contained in:
Feng Lee 2016-07-16 21:01:03 +08:00 committed by GitHub
commit 55b93fa144
1 changed files with 6 additions and 4 deletions

View File

@ -38,7 +38,7 @@
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]). terminate/2, code_change/3]).
-record(state, {started_at, sys_interval, heartbeat, tick_tref}). -record(state, {started_at, sys_interval, heartbeat, tick_tref, version, sysdescr}).
-define(SERVER, ?MODULE). -define(SERVER, ?MODULE).
@ -125,6 +125,8 @@ init([]) ->
% Tick % Tick
{ok, #state{started_at = os:timestamp(), {ok, #state{started_at = os:timestamp(),
heartbeat = start_tick(1000, heartbeat), heartbeat = start_tick(1000, heartbeat),
version = list_to_binary(version()),
sysdescr = list_to_binary(sysdescr()),
tick_tref = start_tick(tick)}, hibernate}. tick_tref = start_tick(tick)}, hibernate}.
handle_call(uptime, _From, State) -> handle_call(uptime, _From, State) ->
@ -141,10 +143,10 @@ handle_info(heartbeat, State) ->
publish(datetime, list_to_binary(datetime())), publish(datetime, list_to_binary(datetime())),
{noreply, State, hibernate}; {noreply, State, hibernate};
handle_info(tick, State) -> handle_info(tick, State = #state{version = Version, sysdescr = Descr}) ->
retain(brokers), retain(brokers),
retain(version, list_to_binary(version())), retain(version, Version),
retain(sysdescr, list_to_binary(sysdescr())), retain(sysdescr, Descr),
{noreply, State, hibernate}; {noreply, State, hibernate};
handle_info(Info, State) -> handle_info(Info, State) ->