Skip to content

Commit

Permalink
rewatch etcd3 if network broke
Browse files Browse the repository at this point in the history
  • Loading branch information
smallnest committed Jul 23, 2020
1 parent 35b07de commit fb13c76
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/etcdv3_discovery.go
Expand Up @@ -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
Expand Down Expand Up @@ -181,15 +182,15 @@ func (d *EtcdV3Discovery) watch() {
return
}

readChanges:
for {
select {
case <-d.stopCh:
log.Info("discovery has been closed")
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
Expand Down

0 comments on commit fb13c76

Please sign in to comment.