View Source dotenv_config (dotenv_config v2.3.3)

Summary

Functions

fetch/1 Get configuration item from the persistent term storage.

get/1 Get configuration item from the persistent term storage. But if it's not found raise an exception.

get_all/0 Get all configuration items from the persistent term storage.

init/2 Load configuration from environment variables and store it in the persistent term storage.

init/2 Load configuration from .env files and override it by environment variables (if duplicate last read place wins) and store it in the persistent term storage. Parameters: Module - module which will be used to parse the configuration (see readme for details) FileNames - list of names of the files to load configuration from Returns: ok - if configuration was successfully loaded and stored {error, Reason} - if there was an error during loading or storing

set/2 Set configuration item in the persistent term storage.

stop/0 Stop config storage and delete all stored configuration.

Types

-type config_item_name() :: binary().
Link to this type

config_item_raw_value/0

View Source
-type config_item_raw_value() :: binary().
-type config_item_type() ::
          simple_config_type() | [exact_value() | simple_config_type()] | convert_function().
-type config_item_value() :: any().
-type convert_function() :: fun((config_item_raw_value()) -> config_item_value()).
-type exact_value() :: {exact, binary()}.
-type parsed_config() :: [{config_item_name(), config_item_value()}].
-type parser() :: [{config_item_name(), config_item_type()}].
-type simple_config_type() :: str | int | bool | json | atom | module | charlist.

Functions

-spec fetch(config_item_name()) -> {ok, config_item_value()} | {error, not_found}.

fetch/1 Get configuration item from the persistent term storage.

-spec get(config_item_name()) -> config_item_value().

get/1 Get configuration item from the persistent term storage. But if it's not found raise an exception.

-spec get_all() -> parsed_config().

get_all/0 Get all configuration items from the persistent term storage.

-spec init(module()) -> ok.

init/2 Load configuration from environment variables and store it in the persistent term storage.

You can set DOTENV_CONFIG_ENV_FILES environment variable to list of files to load configuration from (comma separated).

Environment variables have higher priority than .env files.

Parameters: Module - module which will be used to parse the configuration (see readme for details) Returns: ok - if configuration was successfully loaded and stored {error, Reason} - if there was an error during loading or storing

-spec init(module(), [file:name_all()]) -> ok.

init/2 Load configuration from .env files and override it by environment variables (if duplicate last read place wins) and store it in the persistent term storage. Parameters: Module - module which will be used to parse the configuration (see readme for details) FileNames - list of names of the files to load configuration from Returns: ok - if configuration was successfully loaded and stored {error, Reason} - if there was an error during loading or storing

Link to this function

set(ConfigItemName, ConfigItemValue)

View Source
-spec set(config_item_name(), config_item_value()) -> ok.

set/2 Set configuration item in the persistent term storage.

-spec stop() -> ok.

stop/0 Stop config storage and delete all stored configuration.