Current section
Files
Jump to
Current section
Files
lib/logdot/config.ex
defmodule LogDot.Config do
@moduledoc """
Configuration handling for LogDot.
"""
@default_timeout 5000
@default_retry_attempts 3
@default_retry_base_delay 1000
@default_retry_max_delay 30_000
defstruct [
:api_key,
:hostname,
:entity_name,
:entity_description,
timeout: @default_timeout,
retry_attempts: @default_retry_attempts,
retry_base_delay: @default_retry_base_delay,
retry_max_delay: @default_retry_max_delay,
debug: false
]
@type t :: %__MODULE__{
api_key: String.t() | nil,
hostname: String.t() | nil,
entity_name: String.t() | nil,
entity_description: String.t() | nil,
timeout: pos_integer(),
retry_attempts: pos_integer(),
retry_base_delay: pos_integer(),
retry_max_delay: pos_integer(),
debug: boolean()
}
@spec from_env() :: t()
def from_env do
%__MODULE__{
api_key: Application.get_env(:logdot, :api_key),
hostname: Application.get_env(:logdot, :hostname),
entity_name: Application.get_env(:logdot, :entity_name),
entity_description: Application.get_env(:logdot, :entity_description),
timeout: Application.get_env(:logdot, :timeout, @default_timeout),
retry_attempts: Application.get_env(:logdot, :retry_attempts, @default_retry_attempts),
retry_base_delay: Application.get_env(:logdot, :retry_base_delay, @default_retry_base_delay),
retry_max_delay: Application.get_env(:logdot, :retry_max_delay, @default_retry_max_delay),
debug: Application.get_env(:logdot, :debug, false)
}
end
end