Skip to main content

Crate baukit_config

Crate baukit_config 

Source
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§

BaukitConfig
Standard Baukit sections plus flattened, product-specific configuration.
ConfigLoader
Loads a BaukitConfig using the Baukit precedence and naming conventions.
DatabaseConfig
Plain database connection and pool configuration.
HttpConfig
Configuration for the public HTTP listener.
OpsConfig
Configuration for the separate operations listener.
ParseEnvironmentError
An error returned when a deployment environment name is not supported.
RateLimitConfig
Shared Redis-backed identity and client-IP rate-limit configuration.
RateLimitScopeConfig
Configuration for one token-bucket rate-limit scope.
Secret
A secret value whose formatted representations never reveal its contents.
ShutdownConfig
Configuration for graceful shutdown.
TelemetryConfig
Configuration for traces and log rendering.
TelemetryResourceConfig
Resource identity values consumed by telemetry initialization.
ValidationError
One actionable configuration validation problem.
ValidationErrors
An aggregate of all configuration validation problems.

Enums§

DeploymentEnvironment
The deployment environment attached to configuration and telemetry signals.
Environment
The deployment environment attached to configuration and telemetry signals.
LoadError
An error that prevents configuration from being loaded for startup.
LogFormat
Selection policy for the stdout log formatter.
RateLimitFailMode
Whether request processing continues when the rate-limit store is unavailable.

Traits§

Validate
A type that checks its configuration invariants before startup.