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:
parent
697673ffb6
commit
a9c61f703d
1 changed files with 4 additions and 1 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue