aboutsummaryrefslogtreecommitdiff
path: root/src/consul_actor.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-12-25 19:19:19 +0100
committerAlex Auvolat <alex@adnab.me>2021-12-25 19:23:18 +0100
commit3b9e75634aa06b6df0519e5d44fd6e5281712d09 (patch)
treed82e14884993895a13cdca78c7388de2e0846f0f /src/consul_actor.rs
parent4d4d453afa3edafe71db2ae60171b8696b38a3c9 (diff)
downloaddiplonat-3b9e75634aa06b6df0519e5d44fd6e5281712d09.tar.gz
diplonat-3b9e75634aa06b6df0519e5d44fd6e5281712d09.zip
Allow Diplonat to automatically detect it's private IP
Diffstat (limited to 'src/consul_actor.rs')
-rw-r--r--src/consul_actor.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/consul_actor.rs b/src/consul_actor.rs
index b111f09..61789ca 100644
--- a/src/consul_actor.rs
+++ b/src/consul_actor.rs
@@ -4,7 +4,7 @@ use anyhow::Result;
use log::*;
use serde::{Deserialize, Serialize};
use serde_lexpr::{error, from_str};
-use tokio::{sync::watch, time::delay_for};
+use tokio::{sync::watch, time::sleep};
use crate::{consul, messages};
@@ -35,7 +35,7 @@ fn retry_to_time(retries: u32, max_time: Duration) -> Duration {
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> {
@@ -51,7 +51,7 @@ fn to_parameters(catalog: &consul::CatalogNode) -> Vec<DiplonatConsul> {
}
}
- return r
+ return r;
}
fn to_open_ports(params: &Vec<DiplonatConsul>) -> messages::PublicExposedPorts {
@@ -70,7 +70,7 @@ fn to_open_ports(params: &Vec<DiplonatConsul>) -> messages::PublicExposedPorts {
}
}
- return op
+ return op;
}
impl ConsulActor {
@@ -86,7 +86,7 @@ impl ConsulActor {
tx_open_ports: tx,
node: node.to_string(),
retries: 0,
- }
+ };
}
pub async fn listen(&mut self) -> Result<()> {
@@ -102,15 +102,15 @@ impl ConsulActor {
will_retry_in.as_secs(),
e
);
- delay_for(will_retry_in).await;
- continue
+ sleep(will_retry_in).await;
+ continue;
}
};
self.retries = 0;
let msg = to_open_ports(&to_parameters(&catalog));
debug!("Extracted configuration: {:#?}", msg);
- self.tx_open_ports.broadcast(msg)?;
+ self.tx_open_ports.send(msg)?;
}
}
}