// Project:   scalo
// File:      src/directory_config/mod.rs
// Purpose:   Directory-based YAML config store module root
// Language:  Rust
//
// License:   Apache-2.0
// Copyright: (c) 2026 HYPERI PTY LIMITED

//! # 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
//!
//! ```rust,no_run
//! use scalo::directory_config::{DirectoryConfigStore, DirectoryConfigStoreConfig};
//! use std::path::PathBuf;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! 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?;
//! # Ok(())
//! # }
//! ```

pub mod error;
mod refresh;
pub mod store;
pub mod types;

#[cfg(feature = "directory-config-git")]
pub mod git;

// Re-exports for convenience
pub use error::{DirectoryConfigError, DirectoryConfigResult};
pub use store::DirectoryConfigStore;
pub use types::{ChangeEvent, ChangeOperation, DirectoryConfigStoreConfig, WriteMode, WriteResult};
