Revisit docs about how could we "reconnect" when failure.

See also:

   https://github.com/etcd-cpp-apiv3/etcd-cpp-apiv3/issues/73#issuecomment-888150328


Signed-off-by: Tao He <sighingnow@gmail.com>
This commit is contained in:
Tao He 2021-07-28 17:57:33 +08:00
parent 3d4fa143e0
commit 891dc7bedf
1 changed files with 3 additions and 2 deletions

View File

@ -507,11 +507,12 @@ void wait_for_connection(Client &client) {
void initialize_watcher(const std::string &endpoints,
const std::string &prefix,
std::function<void(Response)> callback,
std::unique_ptr<etcd::Watcher> &watcher) {
std::shared_ptr<etcd::Watcher> &watcher) {
Client client(endpoints);
wait_for_connection(client);
watcher->reset(new etcd::Watcher(client, prefix, callback));
watcher->Wait([endpoints, prefix, callback, &watcher](bool cancelled) {
watcher->Wait([endpoints, prefix, callback,
watcher_ref /* keep the shared_ptr alive */, &watcher](bool cancelled) {
if (cancelled) {
return;
}