dynpatch-watcher

Crates.iodynpatch-watcher
lib.rsdynpatch-watcher
version0.1.0
created_at2025-10-15 10:50:57.146079+00
updated_at2025-10-15 10:50:57.146079+00
descriptionFile watching and live config reloading for dynpatch
homepage
repositoryhttps://gitlab.com/TIVisionOSS/crates/dynpatch
max_upload_size
id1884178
size35,639
Eshan Roy (eshanized)

documentation

https://docs.rs/dynpatch-watcher

README

dynpatch-watcher

File watching and live config reloading for dynpatch.

Features

  • File watching: Monitor files for changes using notify
  • Config hot-reloading: Automatically reload configuration files
  • Multiple formats: Support for JSON, TOML, and YAML
  • Lock-free updates: Use arc-swap for thread-safe config access
  • Validation hooks: Validate configs before applying

Example

use dynpatch_watcher::config::{HotConfig, watch};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Deserialize, Serialize)]
struct AppConfig {
    max_connections: usize,
    log_level: String,
}

impl HotConfig for AppConfig {}

fn main() {
    let watcher = watch::<AppConfig, _>("config.toml").unwrap();
    
    loop {
        let config = watcher.get();
        println!("Max connections: {}", config.max_connections);
        std::thread::sleep(std::time::Duration::from_secs(1));
    }
}

Features

  • json (default) - JSON format support
  • toml (default) - TOML format support
  • yaml (default) - YAML format support

License

MIT - See LICENSE file for details

Commit count: 0

cargo fmt