pub struct ConfigWatcher { /* private fields */ }Expand description
Watches a config file for changes and broadcasts validated updates.
Subscribers receive new PipelineConfig values via a
[broadcast::Receiver].
§Panics
This type never panics.
Implementations§
Source§impl ConfigWatcher
impl ConfigWatcher
Sourcepub fn new(
path: PathBuf,
) -> Result<(Self, Receiver<PipelineConfig>), ConfigError>
pub fn new( path: PathBuf, ) -> Result<(Self, Receiver<PipelineConfig>), ConfigError>
Create a new ConfigWatcher for the given config file path.
Returns the watcher and a receiver for config change notifications.
The initial config is not broadcast — use loader::load_from_file
for the initial load.
§Arguments
path— Path to the TOML config file to watch.
§Returns
Ok((ConfigWatcher, Receiver))on success.Err(ConfigError)if the file watcher cannot be created.
§Panics
This function never panics.
§Example
ⓘ
use tokio_prompt_orchestrator::config::watcher::ConfigWatcher;
use std::path::PathBuf;
let (watcher, mut rx) = ConfigWatcher::new(PathBuf::from("pipeline.toml"))?;
tokio::spawn(async move {
while let Ok(config) = rx.recv().await {
println!("Config reloaded: {}", config.pipeline.name);
}
});Sourcepub fn subscribe(&self) -> Receiver<PipelineConfig>
pub fn subscribe(&self) -> Receiver<PipelineConfig>
Subscribe to config change notifications.
Returns a new receiver. Multiple subscribers are supported.
§Panics
This function never panics.
Auto Trait Implementations§
impl !RefUnwindSafe for ConfigWatcher
impl !UnwindSafe for ConfigWatcher
impl Freeze for ConfigWatcher
impl Send for ConfigWatcher
impl Sync for ConfigWatcher
impl Unpin for ConfigWatcher
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request