From 5f7067c8647718220e14a109c1aa0a367fa2e1ef Mon Sep 17 00:00:00 2001 From: Oliver Gould Date: Thu, 21 Jun 2018 11:05:03 -0700 Subject: [PATCH] proxy: Document tls::config::watch_for_config_changes (#1176) While investigating TLS configuration, I found myself wanting a docstring on `tls::config::watch_for_config_changes`. This has one minor change in functionality: now, `future::empty()` is returned instead of `future:ok(())` so that the task never completes. It seems that, ultimately, we'll want to treat it as an error if we lose the ability to receive configuration updates. --- proxy/src/transport/tls/config.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/proxy/src/transport/tls/config.rs b/proxy/src/transport/tls/config.rs index d307cd075..43a3ac507 100644 --- a/proxy/src/transport/tls/config.rs +++ b/proxy/src/transport/tls/config.rs @@ -249,15 +249,27 @@ impl CommonConfig { } +// A Future that, when polled, checks for config updates and publishes them. +pub type PublishConfigs = Box + Send>; + +/// Returns Client and Server config watches, and a task to drive updates. +/// +/// The returned task Future is expected to never complete. +/// +/// If there are no TLS settings, then empty watches are returned. In this case, the +/// Future is never notified. +/// +/// If all references are dropped to _either_ the client or server config watches, all +/// updates will cease for both config watches. pub fn watch_for_config_changes(settings: Conditional<&CommonSettings, ReasonForNoTls>) - -> (ClientConfigWatch, ServerConfigWatch, Box + Send>) + -> (ClientConfigWatch, ServerConfigWatch, PublishConfigs) { let settings = if let Conditional::Some(settings) = settings { settings.clone() } else { let (client_watch, _) = Watch::new(None); let (server_watch, _) = Watch::new(None); - let no_future = future::ok(()); + let no_future = future::empty(); return (client_watch, server_watch, Box::new(no_future)); }; @@ -282,8 +294,8 @@ pub fn watch_for_config_changes(settings: Conditional<&CommonSettings, ReasonFor Ok((client_store, server_store)) }) .then(|_| { - trace!("forwarding to server config watch finished."); - Ok(()) + error!("forwarding to tls config watches finished."); + Err(()) }); // This function and `ServerConfig::no_tls` return `Box>`