Skip to main content

Module flat_env

Module flat_env 

Source
Expand description

Flat environment variable override helpers.

DFE services running in Kubernetes receive configuration via flat env vars set by dfe-engine through Helm. These use single underscores as separators (e.g., DFE_LOADER_KAFKA_BROKERS), which differs from figment’s double-underscore convention for nested keys.

This module provides:

  • Runtime helper functions for reading flat env vars with type conversion
  • The ApplyFlatEnv trait for applying overrides to config structs
  • The Normalize trait for config normalisation after all sources merge
  • A generic load_config function that orchestrates the full cascade

§Usage

The helper functions are designed to be called by #[derive(FlatEnvOverrides)] generated code, but are also usable standalone:

use hyperi_rustlib::config::flat_env::*;

if let Some(host) = flat_env_string("MYAPP", "HOST") {
    println!("Host override: {host}");
}

Structs§

EnvVarDoc
Documentation for a single env var (generated by derive macro).

Traits§

ApplyFlatEnv
Trait for flat environment variable override application.
Normalize
Trait for config normalisation after all sources are merged.

Functions§

flat_env_bool
Read a flat env var as a bool.
flat_env_list
Read a flat env var as a comma-separated list.
flat_env_parsed
Read a flat env var and parse via FromStr.
flat_env_string
Read a flat env var {PREFIX}_{SUFFIX} as a String.
flat_env_string_sensitive
Read a flat env var as a String, masking the value in debug output.
load_config
Load config with full cascade: YAML -> figment env -> flat env -> normalise.