Skip to main content

hyperi_rustlib/directory_config/
mod.rs

1// Project:   hyperi-rustlib
2// File:      src/directory_config/mod.rs
3// Purpose:   Directory-based YAML config store module root
4// Language:  Rust
5//
6// License:   BUSL-1.1
7// Copyright: (c) 2026 HYPERI PTY LIMITED
8
9//! # Directory Config Store
10//!
11//! A directory-based configuration store backed by YAML files. Each YAML file
12//! in the configured directory (or subdirectories) is treated as a "table" and
13//! cached in memory with automatic background polling refresh.
14//!
15//! ## Features
16//!
17//! - **Read API:** `get()`, `get_key()`, `get_as()`, `list_tables()`
18//! - **Write API:** `set()`, `delete_key()` with advisory file locking
19//! - **Subdirectory support:** `loaders/dfe-loader` maps to `loaders/dfe-loader.yaml`
20//! - **Background refresh:** Polling-based (safe for S3/FUSE mounts)
21//! - **Change notifications:** Subscribe via `on_change()`
22//! - **Git integration:** Optional commit-on-write (feature `directory-config-git`)
23//!
24//! ## Example
25//!
26//! ```rust,no_run
27//! use hyperi_rustlib::directory_config::{DirectoryConfigStore, DirectoryConfigStoreConfig};
28//! use std::path::PathBuf;
29//!
30//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
31//! let config = DirectoryConfigStoreConfig {
32//!     directory: PathBuf::from("/etc/myapp/config"),
33//!     ..Default::default()
34//! };
35//!
36//! let mut store = DirectoryConfigStore::new(config).await?;
37//! store.start().await?;
38//!
39//! // Read
40//! let tables = store.list_tables().await;
41//! let value = store.get("my-service").await?;
42//! let host = store.get_key("my-service", "kafka.brokers").await?;
43//!
44//! // Write (if not read-only)
45//! store.set("dfe-loader", "kafka.brokers", "broker:9092".into(), None).await?;
46//!
47//! store.stop().await?;
48//! # Ok(())
49//! # }
50//! ```
51
52pub mod error;
53mod refresh;
54pub mod store;
55pub mod types;
56
57#[cfg(feature = "directory-config-git")]
58pub mod git;
59
60// Re-exports for convenience
61pub use error::{DirectoryConfigError, DirectoryConfigResult};
62pub use store::DirectoryConfigStore;
63pub use types::{ChangeEvent, ChangeOperation, DirectoryConfigStoreConfig, WriteMode, WriteResult};