From fb13c761d3c69d53a26ccf7c88c7899d4822064d Mon Sep 17 00:00:00 2001 From: smallnest Date: Thu, 23 Jul 2020 16:14:53 +0800 Subject: [PATCH] rewatch etcd3 if network broke --- client/etcdv3_discovery.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/etcdv3_discovery.go b/client/etcdv3_discovery.go index 2fc3a1f5..5e4d7e45 100644 --- a/client/etcdv3_discovery.go +++ b/client/etcdv3_discovery.go @@ -149,6 +149,7 @@ func (d *EtcdV3Discovery) RemoveWatcher(ch chan []*KVPair) { } func (d *EtcdV3Discovery) watch() { +rewatch: for { var err error var c <-chan []*store.KVPair @@ -181,7 +182,6 @@ func (d *EtcdV3Discovery) watch() { return } - readChanges: for { select { case <-d.stopCh: @@ -189,7 +189,8 @@ func (d *EtcdV3Discovery) watch() { return case ps := <-c: if ps == nil { - break readChanges + log.Warnf("rewatch %s", d.basePath) + goto rewatch } var pairs []*KVPair // latest servers var prefix string