in src/lib.rs [179:202]
fn create_watcher() -> Result<
(
Debouncer<RecommendedWatcher>,
mpsc::Receiver<Result<Vec<DebouncedEvent>, notify::Error>>,
),
OtelError,
> {
// Create async channel for watcher notifications
let (async_tx, async_rx) = mpsc::channel(1);
// Create watcher with event handler that sends events to async channel
let watcher = new_debouncer(Duration::from_secs(1), move |res| {
let async_tx = async_tx.clone();
futures::executor::block_on(async {
if let Err(e) = async_tx.send(res).await {
error!("error sending watcher notification: {e}");
}
});
})
.map_err(OtelError::WatcherError)?;
// Return watch and receiver
Ok((watcher, async_rx))
}