Skip to content

Commit

Permalink
bugfix:etcdv3 autoreconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenHaoHu committed Feb 20, 2021
1 parent cc938d5 commit 5b3375a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sd/etcdv3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/tls"
"errors"
"fmt"
"time"

"go.etcd.io/etcd/clientv3"
Expand Down Expand Up @@ -212,6 +213,10 @@ func (c *client) Register(s Service) error {
case r := <-c.hbch:
// avoid dead loop when channel was closed
if r == nil {
if err := c.Register(s); err != nil {
fmt.Println(err.Error())
time.Sleep(10 * time.Second)
}
return
}
case <-c.ctx.Done():
Expand Down

0 comments on commit 5b3375a

Please sign in to comment.