diff options
author | Alex Auvolat <alex@adnab.me> | 2023-02-02 16:10:56 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-02-02 16:10:56 +0100 |
commit | ff14118db7ac838910f4ace03bc24f6dbafc62b3 (patch) | |
tree | da7f088b6236beaf48dd9add76eae6f4837e9e1e /examples | |
parent | d0f40c02b9b74e6e6b852036865ad2b0c0e9370c (diff) | |
download | df-consul-ff14118db7ac838910f4ace03bc24f6dbafc62b3.tar.gz df-consul-ff14118db7ac838910f4ace03bc24f6dbafc62b3.zip |
Exponential backoff retry on catalog watcher
Diffstat (limited to 'examples')
-rw-r--r-- | examples/test.rs | 13 | ||||
-rw-r--r-- | examples/watch_test.rs | 27 |
2 files changed, 31 insertions, 9 deletions
diff --git a/examples/test.rs b/examples/test.rs index b3e6455..7e38c66 100644 --- a/examples/test.rs +++ b/examples/test.rs @@ -1,7 +1,11 @@ +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, @@ -41,13 +45,4 @@ async fn main() { .unwrap() ); } - - println!("== WATCHING EVERYTHING =="); - let mut watch = consul.watch_all_service_health(); - loop { - if watch.changed().await.is_err() { - break; - } - println!("\n{:?}", watch.borrow_and_update()); - } } diff --git a/examples/watch_test.rs b/examples/watch_test.rs new file mode 100644 index 0000000..d4d48a0 --- /dev/null +++ b/examples/watch_test.rs @@ -0,0 +1,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()); + } +} |