aboutsummaryrefslogtreecommitdiff
path: root/src/consul_actor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/consul_actor.rs')
-rw-r--r--src/consul_actor.rs25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/consul_actor.rs b/src/consul_actor.rs
index d66f7fd..b111f09 100644
--- a/src/consul_actor.rs
+++ b/src/consul_actor.rs
@@ -1,14 +1,12 @@
-use crate::consul;
-use crate::messages;
+use std::{cmp, collections::HashSet, time::Duration};
+
use anyhow::Result;
use log::*;
use serde::{Deserialize, Serialize};
use serde_lexpr::{error, from_str};
-use std::cmp;
-use std::collections::HashSet;
-use std::time::Duration;
-use tokio::sync::watch;
-use tokio::time::delay_for;
+use tokio::{sync::watch, time::delay_for};
+
+use crate::{consul, messages};
#[derive(Serialize, Deserialize, Debug)]
pub enum DiplonatParameter {
@@ -32,11 +30,12 @@ pub struct ConsulActor {
fn retry_to_time(retries: u32, max_time: Duration) -> Duration {
// 1.2^x seems to be a good value to exponentially increase time at a good pace
- // eg. 1.2^32 = 341 seconds ~= 5 minutes - ie. after 32 retries we wait 5 minutes
+ // eg. 1.2^32 = 341 seconds ~= 5 minutes - ie. after 32 retries we wait 5
+ // minutes
return Duration::from_secs(cmp::min(
max_time.as_secs(),
1.2f64.powf(retries as f64) as u64,
- ));
+ ))
}
fn to_parameters(catalog: &consul::CatalogNode) -> Vec<DiplonatConsul> {
@@ -52,7 +51,7 @@ fn to_parameters(catalog: &consul::CatalogNode) -> Vec<DiplonatConsul> {
}
}
- return r;
+ return r
}
fn to_open_ports(params: &Vec<DiplonatConsul>) -> messages::PublicExposedPorts {
@@ -71,7 +70,7 @@ fn to_open_ports(params: &Vec<DiplonatConsul>) -> messages::PublicExposedPorts {
}
}
- return op;
+ return op
}
impl ConsulActor {
@@ -87,7 +86,7 @@ impl ConsulActor {
tx_open_ports: tx,
node: node.to_string(),
retries: 0,
- };
+ }
}
pub async fn listen(&mut self) -> Result<()> {
@@ -104,7 +103,7 @@ impl ConsulActor {
e
);
delay_for(will_retry_in).await;
- continue;
+ continue
}
};
self.retries = 0;