Skip to main content

Module env_compat

Module env_compat 

Source
Expand description

Environment variable compatibility layer.

Provides utilities for reading environment variables with support for:

  • Legacy variable name aliases with deprecation warnings
  • Standard naming conventions (PG*, KAFKA_, VAULT_, AWS_*)
  • Graceful migration from old to new variable names

§How it works

When reading an environment variable:

  1. First try the standard (preferred) name
  2. If not set, try legacy (deprecated) names
  3. If a legacy name is used, log a deprecation warning
  4. Standard name always takes precedence if both are set

§Example

use hyperi_rustlib::config::env_compat::EnvVar;

// Define a variable with legacy aliases
let host = EnvVar::new("PGHOST")
    .with_legacy("POSTGRESQL_HOST")
    .with_legacy("PG_HOST")
    .get();

// Or use the builder for multiple variables
let vars = EnvVarSet::new("KAFKA")
    .var("BOOTSTRAP_SERVERS", &["BROKERS"])
    .var("SASL_USERNAME", &["SASL_USER"])
    .build();

Modules§

aws
AWS environment variables (official SDK naming).
clickhouse
ClickHouse environment variables.
kafka
Kafka environment variables.
postgres
PostgreSQL environment variables (libpq standard).
vault
Vault/OpenBao environment variables.

Structs§

EnvVar
Environment variable with optional legacy aliases.

Functions§

load_all_standard
Load all standard environment variables into a HashMap.