fix: resolve Mix.env at compile time in Vereinfacht client

Mix.env() is not available in production releases. Use module
attribute so it is only evaluated at compile time.
This commit is contained in:
Moritz 2026-03-10 18:15:07 +01:00
parent 697673ffb6
commit a9c61f703d
Signed by: moritz
GPG key ID: 1020A035E5DD0824

View file

@ -92,10 +92,13 @@ defmodule Mv.Vereinfacht.Client do
@sync_timeout_ms 5_000 @sync_timeout_ms 5_000
# Resolved at compile time so Mix is never called at runtime (Mix is not available in releases).
@env Mix.env()
# In test, skip retries so sync fails fast when no API is running (avoids log spam and long waits). # In test, skip retries so sync fails fast when no API is running (avoids log spam and long waits).
defp req_http_options do defp req_http_options do
opts = [receive_timeout: @sync_timeout_ms] opts = [receive_timeout: @sync_timeout_ms]
if Mix.env() == :test, do: [retry: false] ++ opts, else: opts if @env == :test, do: [retry: false] ++ opts, else: opts
end end
defp post_and_parse_contact(url, body, api_key) do defp post_and_parse_contact(url, body, api_key) do