Files
mytheclipse/crates/mytheclipse-config
asepharyana 8106f8943e feat: add 4 new crates (queue, tracing, http, cli) + enhancements to existing crates
New crates:
- mytheclipse-queue: unified job queue with WorkerPool, retry/backoff, DLQ
  Backends: in-memory (default), Redis, NATS, PostgreSQL
- mytheclipse-tracing: tracing subscriber layers with env filter + OTLP/Jaeger export
- mytheclipse-http: HTTP client/server with timeout + tracing, axum server
- mytheclipse-cli: CLI framework with clap derive, built-in subcommands

Enhancements to existing crates:
- mytheclipse-core: SemaphorePool, LeaderElection, HealthRegistry/HealthCheck
- mytheclipse-cache: AutoRefreshCache (bg refresh on miss), CacheMetrics
- mytheclipse-config: ConfigSchema for JSON Schema generation
- mytheclipse-storage: MultipartUploadDriver trait
- mytheclipse-crypto: PASETO v4.local token support

All features compile with --all-features; tests + clippy pass clean.
2026-08-29 16:05:02 +07:00
..

mytheclipse-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 mytheclipse_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 mytheclipse_config::DynamicConfig;
# use serde::Deserialize;
# #[derive(Debug, Deserialize, Clone)] struct AppConfig { port: u16 }

let cfg = DynamicConfig::<AppConfig>::watch_files(
    vec!["config.yaml".into()],
    || mytheclipse_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());
    }
});