summaryrefslogtreecommitdiff
path: root/examples/watch_test.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/watch_test.rs')
-rw-r--r--examples/watch_test.rs27
1 files changed, 27 insertions, 0 deletions
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());
+ }
+}