summaryrefslogtreecommitdiff
path: root/examples/watch_test.rs
blob: d4d48a00e9d290cbfbaaf321e58a2fe440aa715d (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
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());
    }
}