View Source Iteraptor.Config (iteraptor v1.14.0)

Extra functions to deal with runtime configuration.

Link to this section Summary

Functions

Reads the application config and recursively changes all the {:key, "VAR"} tuples with runtime system environment read from "VAR".

Link to this section Functions

Link to this function

from_env(app, converter \\ & &1, key \\ :system)

View Source
@spec from_env(app :: atom(), converter :: (binary() -> any()), key :: atom()) :: :ok

Reads the application config and recursively changes all the {:key, "VAR"} tuples with runtime system environment read from "VAR".

Default value for :key is :system, but it might be adjusted to avoid clashes with other libraries implementing {:system, "FOO"} functionality, like Phoenix and/or Ecto.

examples

Examples:

iex> System.put_env("FOO", "42")
iex> Application.put_env(
...>   :iteraptor,
...>   :key,
...>   [value: [value: {:my_system, "FOO"}]],
...>   persistent: true
...> )
iex> Application.get_all_env(:iteraptor)
[key: [value: [value: {:my_system, "FOO"}]]]
iex> Iteraptor.Config.from_env(:iteraptor, &String.to_integer/1, :my_system)
iex> Application.get_all_env(:iteraptor)
[key: [value: [value: 42]]]