add config

This commit is contained in:
anlicheng 2023-08-28 16:19:00 +08:00
parent cdb15ec8f0
commit 0ee5567198

View File

@ -121,7 +121,7 @@ callback_mode() ->
%%
handle_event(cast, {reload, NEndpoint}, disconnected, State = #state{endpoint = Endpoint}) ->
lager:warning("[iot_endpoint] state_name: disconnected, reload endpoint, old: ~p, new: ~p", [Endpoint, Endpoint, NEndpoint]),
lager:warning("[iot_endpoint] state_name: disconnected, reload endpoint, old: ~p, new: ~p", [Endpoint, NEndpoint]),
{keep_state, State#state{endpoint = NEndpoint}};
handle_event(cast, {reload, NEndpoint = #endpoint{name = Name}}, connected, State = #state{endpoint = Endpoint, timer_map = TimerMap, postman_pid = PostmanPid}) ->
@ -202,7 +202,7 @@ handle_event(info, {timeout, _, {repost_ticker, NorthData = #north_data{id = Id}
handle_event(info, {timeout, _, {repost_ticker, _}}, disconnected, State) ->
{keep_state, State};
handle_event(info, {timeout, _, create_postman}, disconnected, State = #state{endpoint = Endpoint = #endpoint{name = Name}, window_size = WindowSize}) ->
handle_event(info, {timeout, _, create_postman}, disconnected, State = #state{endpoint = Endpoint = #endpoint{name = Name, config = Config}, window_size = WindowSize}) ->
lager:debug("[iot_endpoint] endpoint: ~p, create postman", [Name]),
try
{ok, PostmanPid} = create_postman(Endpoint),
@ -210,7 +210,7 @@ handle_event(info, {timeout, _, create_postman}, disconnected, State = #state{en
Actions = lists:map(fun(_) -> {next_event, info, fetch_next} end, lists:seq(1, WindowSize)),
{next_state, connected, State#state{endpoint = Endpoint, postman_pid = PostmanPid, timer_map = maps:new(), flight_num = 0}, Actions}
catch _:Error ->
lager:warning("[iot_endpoint] endpoint: ~p, create postman get error: ~p", [Name, Error]),
lager:warning("[iot_endpoint] endpoint: ~p, config: ~p, create postman get error: ~p", [Name, Config, Error]),
erlang:start_timer(?RETRY_INTERVAL, self(), create_postman),
{keep_state, State#state{endpoint = Endpoint, postman_pid = undefined}}