pub fn watch_channel(watcher: ProxyWatcher) -> Receiver<ProxyConfig>Available on crate feature
tokio only.Expand description
The tokio bridge, behind the tokio feature (off by default).
Drive watcher into a tokio::sync::watch channel (clone watch::Receiver for fan-out).
Starts at ProxyWatcher::current. Errors dropped; identical snapshots not republished;
last receiver drop ends the task. Panics outside a tokio runtime.
Configuration only. WatchEvent also carries WatchHealth,
and this channel
drops it: a route that dies without changing the configuration publishes nothing here.
Read liveness from ProxyWatcher::state, or poll the Stream directly, and use
this for fanning the configuration out to many tasks.
let mut rx = proxy_watch::watch_channel(proxy_watch::ProxyWatcher::new()?);
let mirror = rx.clone();
tokio::spawn(async move {
println!("another task sees {:?}", mirror.borrow().effective);
});
while rx.changed().await.is_ok() {
println!("changed to {:?}", rx.borrow_and_update().effective);
}