Skip to main content

Module directory_config

Module directory_config 

Source
Available on crate feature directory-config only.
Expand description

§Directory Config Store

A directory-based configuration store backed by YAML files. Each YAML file in the configured directory (or subdirectories) is treated as a “table” and cached in memory with automatic background polling refresh.

§Features

  • Read API: get(), get_key(), get_as(), list_tables()
  • Write API: set(), delete_key() with advisory file locking
  • Subdirectory support: loaders/dfe-loader maps to loaders/dfe-loader.yaml
  • Background refresh: Polling-based (safe for S3/FUSE mounts)
  • Change notifications: Subscribe via on_change()
  • Git integration: Optional commit-on-write (feature directory-config-git)

§Example

use hyperi_rustlib::directory_config::{DirectoryConfigStore, DirectoryConfigStoreConfig};
use std::path::PathBuf;

let config = DirectoryConfigStoreConfig {
    directory: PathBuf::from("/etc/myapp/config"),
    ..Default::default()
};

let mut store = DirectoryConfigStore::new(config).await?;
store.start().await?;

// Read
let tables = store.list_tables().await;
let value = store.get("my-service").await?;
let host = store.get_key("my-service", "kafka.brokers").await?;

// Write (if not read-only)
store.set("dfe-loader", "kafka.brokers", "broker:9092".into(), None).await?;

store.stop().await?;

Re-exports§

pub use error::DirectoryConfigError;
pub use error::DirectoryConfigResult;
pub use store::DirectoryConfigStore;
pub use types::ChangeEvent;
pub use types::ChangeOperation;
pub use types::DirectoryConfigStoreConfig;
pub use types::WriteMode;
pub use types::WriteResult;

Modules§

error
store
types