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.rs22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/proxy_config.rs b/src/proxy_config.rs
index 3e3e62f..d4fe039 100644
--- a/src/proxy_config.rs
+++ b/src/proxy_config.rs
@@ -1,12 +1,12 @@
+use std::collections::HashMap;
use std::net::SocketAddr;
use std::sync::{atomic, Arc};
-use std::collections::HashMap;
use std::{cmp, time::Duration};
use anyhow::Result;
+use futures::future::BoxFuture;
use futures::stream::{FuturesUnordered, StreamExt};
-use futures::future::{BoxFuture};
use log::*;
use tokio::{sync::watch, time::sleep};
@@ -45,7 +45,11 @@ fn retry_to_time(retries: u32, max_time: Duration) -> Duration {
));
}
-fn parse_tricot_tag(tag: &str, target_addr: SocketAddr, add_headers: &[(String, String)]) -> Option<ProxyEntry> {
+fn parse_tricot_tag(
+ tag: &str,
+ target_addr: SocketAddr,
+ add_headers: &[(String, String)],
+) -> Option<ProxyEntry> {
let splits = tag.split(' ').collect::<Vec<_>>();
if (splits.len() != 2 && splits.len() != 3) || splits[0] != "tricot" {
return None;
@@ -89,10 +93,13 @@ fn parse_consul_catalog(catalog: &ConsulNodeCatalog) -> Vec<ProxyEntry> {
_ => match catalog.node.address.parse() {
Ok(ip) => ip,
_ => {
- warn!("Could not get address for service {} at node {}", svc.service, catalog.node.node);
+ warn!(
+ "Could not get address for service {} at node {}",
+ svc.service, catalog.node.node
+ );
continue;
}
- }
+ },
};
let addr = SocketAddr::new(ip_addr, svc.port);
@@ -124,7 +131,7 @@ pub fn spawn_proxy_config_task(consul: Consul) -> watch::Receiver<Arc<ProxyConfi
let (tx, rx) = watch::channel(Arc::new(ProxyConfig {
entries: Vec::new(),
}));
-
+
let consul = Arc::new(consul);
tokio::spawn(async move {
@@ -182,7 +189,8 @@ pub fn spawn_proxy_config_task(consul: Consul) -> watch::Receiver<Arc<ProxyConfi
watch_state.retries += 1;
watch_state.last_idx = None;
- let will_retry_in = retry_to_time(watch_state.retries, Duration::from_secs(600));
+ let will_retry_in =
+ retry_to_time(watch_state.retries, Duration::from_secs(600));
error!(
"Failed to query consul for node {}. Will retry in {}s. {}",
node,