Expand description
Layered, validated configuration conventions for Baukit services.
ConfigLoader applies configuration in this order: serde-backed defaults,
an optional local file, then environment variables. Environment variables use
an application prefix and a double-underscore separator, such as
MYAPP__HTTP__PORT=8080. A local .env file is loaded only when the loader’s
deployment Environment is Environment::Local.
Collection-valued environment variables use JSON array syntax, for example
MYAPP__HTTP__CORS_ALLOWED_ORIGINS=["https://app.example.com"]. Scalar
environment values retain their exact source strings, including values that
look numeric, so secret-string preservation is unchanged.
http.cors_allowed_origins is registered automatically; product collection
fields must be declared with ConfigLoader::environment_collection.
Durations in the standard sections are represented as Duration values and
deserialize from integer seconds.
Shared environment and log-format vocabulary lives in the dependency-light
baukit-core crate and is re-exported here. This lets configuration and
telemetry use identical types without making configuration depend on the
OpenTelemetry exporter stack.
§Example
use baukit_config::{BaukitConfig, ConfigLoader, Environment, Validate, ValidationErrors};
use serde::Deserialize;
#[derive(Debug, Default, Deserialize)]
#[serde(default)]
struct ProductConfig {
feature_name: Option<String>,
}
impl Validate for ProductConfig {
fn validate(&self) -> Result<(), ValidationErrors> {
Ok(())
}
}
let config: BaukitConfig<ProductConfig> =
ConfigLoader::new("myapp", Environment::Local)?.load()?;Structs§
- Baukit
Config - Standard Baukit sections plus flattened, product-specific configuration.
- Config
Loader - Loads a
BaukitConfigusing the Baukit precedence and naming conventions. - Database
Config - Plain database connection and pool configuration.
- Http
Config - Configuration for the public HTTP listener.
- OpsConfig
- Configuration for the separate operations listener.
- Parse
Environment Error - An error returned when a deployment environment name is not supported.
- Rate
Limit Config - Shared Redis-backed identity and client-IP rate-limit configuration.
- Rate
Limit Scope Config - Configuration for one token-bucket rate-limit scope.
- Secret
- A secret value whose formatted representations never reveal its contents.
- Shutdown
Config - Configuration for graceful shutdown.
- Telemetry
Config - Configuration for traces and log rendering.
- Telemetry
Resource Config - Resource identity values consumed by telemetry initialization.
- Validation
Error - One actionable configuration validation problem.
- Validation
Errors - An aggregate of all configuration validation problems.
Enums§
- Deployment
Environment - The deployment environment attached to configuration and telemetry signals.
- Environment
- The deployment environment attached to configuration and telemetry signals.
- Load
Error - An error that prevents configuration from being loaded for startup.
- LogFormat
- Selection policy for the stdout log formatter.
- Rate
Limit Fail Mode - Whether request processing continues when the rate-limit store is unavailable.
Traits§
- Validate
- A type that checks its configuration invariants before startup.