pub struct ConfigWatcher { /* private fields */ }Expand description
Watches a config file for changes and broadcasts new configs via a watch channel.
Uses tokio::fs::metadata() polling to detect modification time changes.
When a change is detected, the file is re-read, parsed, and validated.
Only valid configs are broadcast; invalid files log a warning and are skipped.
Implementations§
Source§impl ConfigWatcher
impl ConfigWatcher
Sourcepub fn new(config_path: PathBuf, poll_interval: Duration) -> Result<Self>
pub fn new(config_path: PathBuf, poll_interval: Duration) -> Result<Self>
Create a new watcher for the given config file.
Loads the initial config immediately and makes it available via subscribe().
Sourcepub fn from_config(
config_path: PathBuf,
poll_interval: Duration,
config: AgentZeroConfig,
) -> Self
pub fn from_config( config_path: PathBuf, poll_interval: Duration, config: AgentZeroConfig, ) -> Self
Create a watcher from an already-loaded config (avoids double-load at startup).
Sourcepub fn subscribe(&self) -> Receiver<AgentZeroConfig>
pub fn subscribe(&self) -> Receiver<AgentZeroConfig>
Get a receiver to subscribe to config changes.
Sourcepub fn current(&self) -> AgentZeroConfig
pub fn current(&self) -> AgentZeroConfig
Get the current config snapshot.
Auto Trait Implementations§
impl Freeze for ConfigWatcher
impl RefUnwindSafe for ConfigWatcher
impl Send for ConfigWatcher
impl Sync for ConfigWatcher
impl Unpin for ConfigWatcher
impl UnsafeUnpin for ConfigWatcher
impl UnwindSafe for ConfigWatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more