Use proper timeout for API calls

This commit is contained in:
Mikko Ahlroth 2022-09-13 07:53:56 +03:00
parent 950e0896e7
commit 0a2b7a9892

View file

@ -118,7 +118,8 @@ defmodule GeoTherminator.PumpAPI.Device.Server do
[status, registers, opstat] = [status, registers, opstat] =
Task.async_stream( Task.async_stream(
[&Device.API.status/2, &Device.API.register_info/2, &Device.API.opstat/2], [&Device.API.status/2, &Device.API.register_info/2, &Device.API.opstat/2],
& &1.(user, state.device) & &1.(user, state.device),
timeout: Application.get_env(:geo_therminator, :api_timeout)
) )
|> Enum.map(fn {:ok, val} -> val end) |> Enum.map(fn {:ok, val} -> val end)