aboutsummaryrefslogtreecommitdiff
path: root/src/diplonat.rs
blob: a4cb7877ca4493baa5e93c706699285c234f01e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use anyhow::Result;
use futures::future::try_join_all;
use log::*;
use crate::consul_actor::ConsulActor;
use crate::environment::Environment;

pub struct Diplonat {
  consul: ConsulActor
}

impl Diplonat {
  pub async fn new() -> Result<Self> {
    let env = Environment::new()?;

    let ctx = Self {
      consul: ConsulActor::new(&env.consul_url, &env.consul_node_name)
    };

    return Ok(ctx);
  }

  pub async fn listen(&mut self) -> Result<()> {
    try_join_all(vec![
      self.consul.listen()
    ]).await?;

    return Ok(());
  }
}