summaryrefslogtreecommitdiff
path: root/examples/watch_test.rs
blob: c697a5339abd6079400aa92c3b518381aa5139e1 (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
use std::time::Duration;

use df_consul::*;

#[tokio::main]
async fn main() {
    pretty_env_logger::init();

    let config = Config {
        addr: "http://localhost:8500".into(),
        ca_cert: None,
        tls_skip_verify: false,
        client_cert: None,
        client_key: None,
    };

    let consul = Consul::new(config, "").unwrap();

    println!("== WATCHING EVERYTHING ==");
    let mut watch = consul.watch_all_service_health(Duration::from_secs(30));
    loop {
        if watch.changed().await.is_err() {
            break;
        }
        //println!("\n{:?}", watch.borrow_and_update());
        println!("changed, {} values", watch.borrow_and_update().len());
    }
}