Files
mytheclipse/crates/corex-config/README.md
T
asepharyana d119821339 feat: add panic tracking and logging with PanicTracker
- Implemented PanicTracker to log panics using tracing within a dedicated span.
- Introduced PanicInfo struct to capture panic details.
- Added tests for panic catching and hook restoration.

feat: implement token-bucket rate limiter

- Created RateLimiter to manage token consumption with configurable rates and burst capacity.
- Added methods for acquiring tokens and checking available tokens.
- Included tests for rate limiting behavior and token availability.

feat: add automatic retry with exponential backoff

- Developed retry function to handle transient errors with configurable retry strategies.
- Introduced RetryConfig for customizing retry behavior and jitter.
- Added tests for various retry scenarios and error handling.

feat: implement graceful shutdown coordination

- Created ShutdownManager to manage shutdown signals and task completion.
- Introduced ShutdownSignal for tasks to observe shutdown requests.
- Added tests for shutdown request handling and task draining.

feat: add timeout functionality for async operations

- Implemented with_timeout function to enforce execution time limits on futures.
- Created Timeout struct for wrapping futures with a deadline.
- Added tests for timeout behavior and error mapping.
2026-08-28 21:46:18 +07:00

1.3 KiB

corex-config

Type-safe, dynamic configuration: load .env, YAML, JSON, or TOML directly into a typed Rust struct, merge multiple sources with environment variables taking priority, and optionally hot-reload when the source files change.

Features

  • env (default) — .env file loading via dotenvy.
  • yaml / toml (default) — structured file parsing (.json is always available).
  • hot-reload (default) — watch files and swap in a freshly reloaded value.

Usage

use serde::Deserialize;
use corex_config::ConfigLoader;

#[derive(Debug, Deserialize, Clone)]
struct AppConfig {
    port: u16,
    database_url: String,
}

let config: AppConfig = ConfigLoader::new()
    .merge_file("config.yaml".as_ref())?
    .merge_env("APP")   // APP_PORT, APP_DATABASE_URL override the file
    .build()?;

Hot-reload

use corex_config::DynamicConfig;
# use serde::Deserialize;
# #[derive(Debug, Deserialize, Clone)] struct AppConfig { port: u16 }

let cfg = DynamicConfig::<AppConfig>::watch_files(
    vec!["config.yaml".into()],
    || corex_config::ConfigLoader::new().merge_file("config.yaml".as_ref())?.build(),
)?;

let mut changes = cfg.subscribe();
tokio::spawn(async move {
    while changes.recv().await.is_ok() {
        println!("config reloaded: {:?}", cfg.get());
    }
});