lacoctelera

Module configuration

Source
Expand description

La Coctelera configuration module.

§Description

This module includes all the definitions for the app’s settings and the objects that automate reading the configuration from files or environment variables and parsing them to Rust’s native types.

Some settings must be overridden by environment variables. All the environment variables that are meant to be used within this module shall use the prefix LACOCTELERA.

§Settings

The settings of the application may be set via 2 methods:

  • Using the configuration files located in the config folder.
  • Using environment variables.

The former is advised for settings that usually take the same values and don’t include any value that shall not be exposed to the public (passwords, tokens, …). The latter is advised for settings that we only intend to set for a limited amount of time, i.e. a debug session, or contain private values.

§Environment Variables

The following environment variables are accepted by the application:

  • RUN_MODE: devel, prod. This variable shall take a value that refers to a configuration file in the config folder. The settings found there will overridden the settings found in base.toml. When not set, prod is considered as run mode.

Variables defined within configuration files can be overridden using LACOCTELERA prefix. Variables need to be scoped in the same way as they are found in the configuration files. For example, to override LogSettings::tracing_level:

$ LACOCTELERA__APPLICATION__TRACING_LEVEL=trace ./lacoctelera

Note that the scope separator is a double _.

When multiple configuration variables are needed to be overridden, it is advised to create a local.toml file within the config folder.

§Configuration Files

All the required configuration variables are found in: base.toml, prod.toml and devel.toml. The former refers to common settings that are usually applied to both running scenarios: production and development. Any variable found there can be overridden if defined on any of the latter files.

The descriptions for each variable are found in the Structs docs:

Structs§