From 31c01611481ed307fb5c6ef8c3aa7f08ea1567f9 Mon Sep 17 00:00:00 2001 From: Tao He Date: Fri, 8 Apr 2022 16:41:58 +0800 Subject: [PATCH] Revert "Update Watcher re-connection sample." This reverts commit 23394ab9bbc5af55f02af39ec1a6f2f8ef260628. --- README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index af3b2e0..6633cce 100644 --- a/README.md +++ b/README.md @@ -586,14 +586,11 @@ void initialize_watcher(const std::string &endpoints, wait_for_connection(client); watcher->reset(new etcd::Watcher(client, prefix, callback)); watcher->Wait([endpoints, prefix, callback, - /* watcher reference keep the shared_ptr alive */, &watcher](bool cancelled) -> bool { + watcher_ref /* keep the shared_ptr alive */, &watcher](bool cancelled) { if (cancelled) { - return false; // No reactivate watcher (default behaviour). + return; } - - etcd::Client client(endpoints); - wait_for_connection(client); - return true; // Reactivate watcher. + initialize_watcher(endpoints, prefix, callback, watcher); }); } ``` @@ -604,7 +601,7 @@ std::function callback = printResponse; const std::string prefix = "/test/key"; // the watcher initialized in this way will auto re-connect to etcd -std::shared_ptr watcher; +std::unique_ptr watcher; initialize_watcher(endpoints, prefix, callback, watcher); ```