Fix Elixir integration record mistake

This commit is contained in:
Mikko Ahlroth 2023-01-14 00:51:41 +02:00
parent b55ff1438c
commit f469796260
3 changed files with 12 additions and 6 deletions

View file

@ -121,7 +121,9 @@ defmodule GeoTherminator.PumpAPI.Auth.Server do
{:ok, state} {:ok, state}
else else
_ -> :error err ->
Logger.error("Could not auth or fetch installations! #{inspect(err)}")
:error
end end
end end
end end

View file

@ -1,10 +1,12 @@
defmodule GeoTherminator.PumpAPI.Device.Server do defmodule GeoTherminator.PumpAPI.Device.Server do
require Logger
require GeoTherminator.PumpAPI.Auth.InstallationInfo
use GenServer use GenServer
import GeoTherminator.TypedStruct import GeoTherminator.TypedStruct
alias GeoTherminator.PumpAPI.Device alias GeoTherminator.PumpAPI.Device
alias GeoTherminator.PumpAPI.Auth.InstallationInfo alias GeoTherminator.PumpAPI.Auth.InstallationInfo
alias GeoTherminator.PumpAPI.Auth.Server, as: AuthServer alias GeoTherminator.PumpAPI.Auth.Server, as: AuthServer
require Logger
defmodule Options do defmodule Options do
deftypedstruct(%{ deftypedstruct(%{
@ -26,7 +28,7 @@ defmodule GeoTherminator.PumpAPI.Device.Server do
@spec start_link(Options.t()) :: GenServer.on_start() @spec start_link(Options.t()) :: GenServer.on_start()
def start_link(opts) do def start_link(opts) do
GenServer.start_link(__MODULE__, opts, GenServer.start_link(__MODULE__, opts,
name: {:via, Registry, {Device.Registry, opts.installation.id}} name: {:via, Registry, {Device.Registry, InstallationInfo.record(opts.installation, :id)}}
) )
end end
@ -119,7 +121,7 @@ defmodule GeoTherminator.PumpAPI.Device.Server do
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) timeout: Application.fetch_env!(:geo_therminator, :api_timeout)
) )
|> Enum.map(fn {:ok, val} -> val end) |> Enum.map(fn {:ok, val} -> val end)
@ -133,7 +135,7 @@ defmodule GeoTherminator.PumpAPI.Device.Server do
Process.send_after( Process.send_after(
self(), self(),
:refresh_status, :refresh_status,
Application.get_env(:geo_therminator, :api_refresh) Application.fetch_env!(:geo_therminator, :api_refresh)
) )
end end
end end

View file

@ -1,4 +1,5 @@
defmodule GeoTherminatorWeb.MainLive.Index do defmodule GeoTherminatorWeb.MainLive.Index do
require Logger
use GeoTherminatorWeb, :live_view use GeoTherminatorWeb, :live_view
@impl Phoenix.LiveView @impl Phoenix.LiveView
@ -55,7 +56,8 @@ defmodule GeoTherminatorWeb.MainLive.Index do
) )
end end
_ -> err ->
Logger.debug("Error starting auth server: #{inspect(err)}")
assign(socket, error: true) assign(socket, error: true)
end end
end end