aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2020-05-22 12:29:55 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2020-05-22 12:29:55 +0200
commit4cebe77b6fcc8260ccccece61799a11f4898a0b9 (patch)
tree4a1d4f0c0a3c516f16e736e8522c726b9451c031
parentefbbc17f82b3a2af80ee4e655528fff09f7ca401 (diff)
downloaddiplonat-4cebe77b6fcc8260ccccece61799a11f4898a0b9.tar.gz
diplonat-4cebe77b6fcc8260ccccece61799a11f4898a0b9.zip
Consul Actor basic logic works
-rw-r--r--src/consul_actor.rs6
-rw-r--r--src/main.rs14
2 files changed, 10 insertions, 10 deletions
diff --git a/src/consul_actor.rs b/src/consul_actor.rs
index c87874d..b26c2dd 100644
--- a/src/consul_actor.rs
+++ b/src/consul_actor.rs
@@ -23,7 +23,7 @@ fn retry_to_time(retries: u32, max_time: Duration) -> Duration {
}
impl ConsulActor {
- fn new(url: &str, node: &str) -> Self {
+ pub fn new(url: &str, node: &str) -> Self {
let (tx, rx) = watch::channel(messages::OpenPorts{ports: Vec::new() });
return Self {
consul: Consul::new(url),
@@ -34,7 +34,7 @@ impl ConsulActor {
};
}
- async fn listen(&mut self) -> Result<()> {
+ pub async fn listen(&mut self) -> Result<()> {
loop {
let catalog = match self.consul.watch_node(&self.node).await {
Ok(c) => c,
@@ -46,6 +46,8 @@ impl ConsulActor {
continue;
}
};
+
+ info!("{:#?}", catalog);
}
}
}
diff --git a/src/main.rs b/src/main.rs
index 4fee661..fe4c767 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,21 +6,19 @@ mod consul_actor;
//use std::collections::HashMap;
//use igd::PortMappingProtocol;
use log::*;
-use consul::*;
+use consul_actor::*;
#[tokio::main]
async fn main() {
- pretty_env_logger::init();
- info!("Starting Diplonat");
+ pretty_env_logger::init();
+ info!("Starting Diplonat");
/*
let diplo = Diplonat::new().await.expect("Setup failed");
diplo.listen().await.expect("A runtime error occured");
*/
- let mut c = Consul::new("http://127.0.0.1:8500");
- let cn = c.watch_node("lheureduthe").await.expect("Failed to fetch API");
- println!("{:#?}", cn);
- let cn2 = c.watch_node("lheureduthe").await.expect("Failed to fetch API");
- println!("{:#?}", cn2);
+
+ let mut ca = ConsulActor::new("http://127.0.0.1:8500", "lheureduthe");
+ ca.listen().await.expect("Oooooops");
/*
let gateway = match search_gateway(Default::default()).await {