This commit is contained in:
anlicheng 2024-11-10 12:48:08 +08:00
parent 0b90c99f06
commit da4bd51e46

View File

@ -94,7 +94,8 @@ handle_call(_Request, _From, State = #state{}) ->
{stop, Reason :: term(), NewState :: #state{}}). {stop, Reason :: term(), NewState :: #state{}}).
handle_cast({forward, LocationCode, DynamicLocationCode, EventType, Params}, State = #state{id = Id, timer_map = TimerMap, pri_key = PriKey, url = Url}) -> handle_cast({forward, LocationCode, DynamicLocationCode, EventType, Params}, State = #state{id = Id, timer_map = TimerMap, pri_key = PriKey, url = Url}) ->
ReqBody = format_event(LocationCode, DynamicLocationCode, EventType, Params, PriKey), ReqBody = format_event(LocationCode, DynamicLocationCode, EventType, Params, PriKey),
catch do_post(Url, Id, ReqBody), Res = catch do_post(Url, Id, ReqBody),
lager:debug("[iot_jinzhi_endpoint] format_data: ~p, post result: ~p", [ReqBody, Res]),
TimerRef = erlang:start_timer(?RETRY_INTERVAL, self(), {repost_ticker, Id, ReqBody}), TimerRef = erlang:start_timer(?RETRY_INTERVAL, self(), {repost_ticker, Id, ReqBody}),
{noreply, State#state{id = Id + 1, timer_map = maps:put(Id, TimerRef, TimerMap)}}. {noreply, State#state{id = Id + 1, timer_map = maps:put(Id, TimerRef, TimerMap)}}.
@ -106,6 +107,7 @@ handle_cast({forward, LocationCode, DynamicLocationCode, EventType, Params}, Sta
{noreply, NewState :: #state{}, timeout() | hibernate} | {noreply, NewState :: #state{}, timeout() | hibernate} |
{stop, Reason :: term(), NewState :: #state{}}). {stop, Reason :: term(), NewState :: #state{}}).
handle_info({ack, Id, Body, RespBody}, State = #state{timer_map = TimerMap, logger_pid = LoggerPid}) -> handle_info({ack, Id, Body, RespBody}, State = #state{timer_map = TimerMap, logger_pid = LoggerPid}) ->
lager:debug("[iot_jinzhi_endpoint] get ack: ~p", [Body]),
%% %%
iot_logger:write(LoggerPid, [Body, RespBody]), iot_logger:write(LoggerPid, [Body, RespBody]),
case maps:take(Id, TimerMap) of case maps:take(Id, TimerMap) of