Lamina.Provider.ApplicationEnv (lamina v0.4.2)
Configuration provider for the OTP application environment.
Allows you to use the configuration from your application enviroment
(typically stored in config/config.exs
et al inside your project).
In order to correctly find configuration for your application you must provide
the otp_app
option, and possibly a second-level configuration key.
This is a very simple wrapper around Application.get_all_env/1
and
Application.get_env/3
. See the Elixir core documentation for more
information.
Examples
Given the following configurations:
import Config
config :lamina,
jigga_watts: 1.21,
time_machine: [model: :delorean, top_speed: 88]
We can retrieve the configurations from the environment:
iex> {:ok, state, _refresh_period} = ApplicationEnv.init(otp_app: :lamina)
...> {:ok, 1.21, :volatile, _state} = ApplicationEnv.fetch_config(:jigga_watts, state)
iex> {:ok, state, _refresh_period} = ApplicationEnv.init(otp_app: :lamina, key: :time_machine)
...> {:ok, :delorean, :volatile, _state} = ApplicationEnv.fetch_config(:model, state)
Summary
Types
Link to this type
key_option()
@type key_option() :: {:key, atom()}
Link to this type
lifetime_option()
@type lifetime_option() :: {:lifetime, Lamina.Provider.lifetime()}
Link to this type
option()
@type option() :: otp_app_option() | key_option() | refresh_period_option() | lifetime_option()
Link to this type
options()
@type options() :: [option()]
Link to this type
otp_app_option()
@type otp_app_option() :: {:otp_app, atom()}
Link to this type
refresh_period_option()
@type refresh_period_option() :: {:refresh_period, pos_integer()}
Link to this type
state()
@type state() :: %{ :otp_app => atom(), :refresh_period => pos_integer(), :lifetime => Lamina.Provider.lifetime(), optional(:key) => atom() }