diplonat/src/diplonat.rs

30 lines
546 B
Rust
Raw Normal View History

2020-05-22 16:41:13 +00:00
use anyhow::Result;
2020-05-21 15:51:30 +00:00
use futures::future::try_join_all;
2020-05-21 20:25:33 +00:00
use log::*;
2020-05-22 16:41:13 +00:00
use crate::consul_actor::ConsulActor;
use crate::environment::Environment;
2020-05-21 20:25:33 +00:00
2020-05-22 16:41:13 +00:00
pub struct Diplonat {
consul: ConsulActor
}
2020-05-22 16:41:13 +00:00
impl Diplonat {
pub async fn new() -> Result<Self> {
let env = Environment::new()?;
2020-05-21 20:25:33 +00:00
2020-05-22 16:41:13 +00:00
let ctx = Self {
consul: ConsulActor::new(&env.consul_url, &env.consul_node_name)
2020-05-09 14:50:38 +00:00
};
2020-05-09 14:27:54 +00:00
2020-05-09 14:50:38 +00:00
return Ok(ctx);
}
2020-05-22 16:41:13 +00:00
pub async fn listen(&mut self) -> Result<()> {
try_join_all(vec![
self.consul.listen()
]).await?;
2020-05-21 13:22:45 +00:00
return Ok(());
2020-05-09 14:50:38 +00:00
}
}