Skip to content

Commit

Permalink
Add watch reset
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxu19830126 committed Jun 5, 2020
1 parent b96ed25 commit 0c0aa24
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions watcher_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ func (w *Watcher) Stop() {
close(w.eventC)
}

// Reset reset and refresh
func (w *Watcher) Reset() {
w.Lock()
defer w.Unlock()

w.conn.Close()
}

func (w *Watcher) resetConn(flag int) {
for {
addr := w.next()
Expand Down Expand Up @@ -112,6 +120,12 @@ func (w *Watcher) resetConnWithProphet(flag int) {
}

func (w *Watcher) watchDog(flag int) {
defer func() {
if r := recover(); r != nil {
go w.watchDog(flag)
}
}()

for {
select {
case <-w.stopC:
Expand Down

0 comments on commit 0c0aa24

Please sign in to comment.