aboutsummaryrefslogtreecommitdiff
path: root/src/proxy_config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/proxy_config.rs')
-rw-r--r--src/proxy_config.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/proxy_config.rs b/src/proxy_config.rs
index e118a33..891fdef 100644
--- a/src/proxy_config.rs
+++ b/src/proxy_config.rs
@@ -1,4 +1,5 @@
use std::net::SocketAddr;
+use std::sync::Arc;
use std::{cmp, time::Duration};
use log::*;
@@ -74,10 +75,13 @@ fn parse_consul_catalog(catalog: &ConsulNodeCatalog) -> ProxyConfig {
ProxyConfig { entries }
}
-pub fn spawn_proxy_config_task(mut consul: Consul, node: &str) -> watch::Receiver<ProxyConfig> {
- let (tx, rx) = watch::channel(ProxyConfig {
+pub fn spawn_proxy_config_task(
+ mut consul: Consul,
+ node: &str,
+) -> watch::Receiver<Arc<ProxyConfig>> {
+ let (tx, rx) = watch::channel(Arc::new(ProxyConfig {
entries: Vec::new(),
- });
+ }));
let node = node.to_string();
@@ -105,7 +109,7 @@ pub fn spawn_proxy_config_task(mut consul: Consul, node: &str) -> watch::Receive
let config = parse_consul_catalog(&catalog);
debug!("Extracted configuration: {:#?}", config);
- tx.send(config).expect("Internal error");
+ tx.send(Arc::new(config)).expect("Internal error");
}
});