fix endpoint

This commit is contained in:
anlicheng 2025-11-12 15:28:10 +08:00
parent 4405483b9d
commit d0c38854e4

View File

@ -30,19 +30,19 @@ start_link() ->
init([]) -> init([]) ->
SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600}, SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600},
Endpoints = iot_api:get_all_endpoints(), Endpoints = iot_api:get_all_endpoints(),
ChildSpecs = lists:flatmap(fun(EndpointInfo) -> ChildSpecs = lists:filtermap(fun(EndpointInfo) ->
case endpoint:endpoint_record(EndpointInfo) of case endpoint:endpoint_record(EndpointInfo) of
error -> error ->
[]; false;
{ok, Endpoint} -> {ok, Endpoint} ->
case endpoint:is_support(endpoint:get_protocol(Endpoint)) of case endpoint:is_support(endpoint:get_protocol(Endpoint)) of
true -> true ->
[child_spec(Endpoint)]; {true, child_spec(Endpoint)};
false -> false ->
[] false
end end
end end
end, Endpoints), end, Endpoints),
{ok, {SupFlags, ChildSpecs}}. {ok, {SupFlags, ChildSpecs}}.
-spec ensured_endpoint_started(Endpoint :: #endpoint{}) -> {ok, Pid :: pid()} | {error, Reason :: any()}. -spec ensured_endpoint_started(Endpoint :: #endpoint{}) -> {ok, Pid :: pid()} | {error, Reason :: any()}.