aboutsummaryrefslogtreecommitdiff
path: root/src/consul_actor.rs
diff options
context:
space:
mode:
authoradrien <adrien@luxeylab.net>2021-12-28 11:56:12 +0100
committeradrien <adrien@luxeylab.net>2021-12-28 11:56:12 +0100
commit4560622fa125afb8ac5161f8d0e8a353f99f7a38 (patch)
tree0e6b8c716955ea5bb5896c5dc4c8294b69e54137 /src/consul_actor.rs
parent4d4d453afa3edafe71db2ae60171b8696b38a3c9 (diff)
parent7760b9c58fd98dd934a8f553dd7462049f545cf4 (diff)
downloaddiplonat-4560622fa125afb8ac5161f8d0e8a353f99f7a38.tar.gz
diplonat-4560622fa125afb8ac5161f8d0e8a353f99f7a38.zip
Merge pull request 'Allow Diplonat to automatically detect it's private IP' (#12) from autodetect-private-ip into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/diplonat/pulls/12
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)?;
}
}
}