Improve Config.Reader docs
This commit is contained in:
@@ -4,11 +4,24 @@ defmodule Config.Reader do
|
||||
|
||||
## As a provider
|
||||
|
||||
`Config.Reader` can also be used as a `Config.Provider`.
|
||||
When used as a provider, it expects a single argument:
|
||||
which the configuration path (as outlined in
|
||||
`t:Config.Provider.config_path/0`) for the configuration
|
||||
to be read and loaded during the system boot.
|
||||
`Config.Reader` can also be used as a `Config.Provider`. When used
|
||||
as a provider, it expects a single argument: the configuration path
|
||||
(as outlined in `t:Config.Provider.config_path/0`) for the file to
|
||||
be read and loaded during the system boot.
|
||||
|
||||
For example, if you expect the target system to have a config file
|
||||
in an absolute path, you can configure your `mix release` as:
|
||||
|
||||
config_providers: [{Config.Reader, "/etc/config.json"}]
|
||||
|
||||
Or if you want to read a custom path inside the release:
|
||||
|
||||
config_provider: [{Config.Reader, {:system, "RELEASE_ROOT", "/config.exs"}}]
|
||||
|
||||
Note by default Mix releases supports runtime configuration via
|
||||
a `config/releases.exs`. If a `config/releases.exs` exists in your
|
||||
application, it is automatically copied inside the release and
|
||||
automatically set as a config provider.
|
||||
"""
|
||||
|
||||
@behaviour Config.Provider
|
||||
|
||||
@@ -568,13 +568,14 @@ defmodule Mix.Tasks.Release do
|
||||
### Config providers
|
||||
|
||||
Releases also supports custom mechanisms, called config providers, to load
|
||||
any sort of runtime configuration to the system while it boots. For example,
|
||||
any sort of runtime configuration to the system while it boots. For instance,
|
||||
if you need to access a vault or load configuration from a JSON file, it
|
||||
can be achieved with config providers. See the `Config.Provider` for more
|
||||
information and a simple example.
|
||||
can be achieved with config providers. The runtime configuration outlined
|
||||
in the previous section, which is handled by the `Config.Reader` provider.
|
||||
See the `Config.Provider` module for more information and more examples.
|
||||
|
||||
The following options can be set inside your releases key in your `mix.exs`
|
||||
to control how runtime configuration and config providers work:
|
||||
to control how config providers work:
|
||||
|
||||
* `:start_distribution_during_config` - on Erlang/OTP 22+, releases
|
||||
only start the Erlang VM distribution features after the config files
|
||||
|
||||
Reference in New Issue
Block a user