Skip to content
Snippets Groups Projects
Commit e43dc296 authored by pantianying's avatar pantianying
Browse files

fix code

parent a0961343
No related branches found
No related tags found
No related merge requests found
......@@ -422,14 +422,15 @@ func (r *zkRegistry) Subscribe(url *common.URL, notifyListener registry.NotifyLi
time.Sleep(time.Duration(RegistryConnDelay) * time.Second)
continue
}
n := 0
for {
n++
if serviceEvent, err := listener.Next(); err != nil {
logger.Warnf("Selector.watch() = error{%v}", perrors.WithStack(err))
if err.Error() == "listener stopped" {
if n == 1 {
listener.Close()
break
}
listener.Close()
break
} else {
logger.Infof("update begin, service event: %v", serviceEvent.String())
......@@ -437,7 +438,8 @@ func (r *zkRegistry) Subscribe(url *common.URL, notifyListener registry.NotifyLi
}
}
time.Sleep(1e9)
logger.Infof("wait for get subscribe listener, key{%v}", url.Key())
sleepWait(n)
}
}
......@@ -492,3 +494,10 @@ func (r *zkRegistry) IsAvailable() bool {
return true
}
}
func sleepWait(n int) {
wait := time.Duration(200*n) * time.Millisecond
if wait > 3*time.Second {
wait = 3 * time.Second
}
time.Sleep(wait)
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment