only log error if its plus 3

This commit is contained in:
Asim Aslam 2019-01-14 16:09:51 +00:00
parent 39c24baca9
commit f2ac73eae5

View File

@ -255,6 +255,9 @@ func (c *registrySelector) run(name string) {
c.Unlock() c.Unlock()
}() }()
// error counter
var cerr int
for { for {
// exit early if already dead // exit early if already dead
if c.quit() { if c.quit() {
@ -265,11 +268,16 @@ func (c *registrySelector) run(name string) {
w, err := c.so.Registry.Watch( w, err := c.so.Registry.Watch(
registry.WatchService(name), registry.WatchService(name),
) )
if err != nil { if err != nil {
if c.quit() { if c.quit() {
return return
} }
log.Log(err) cerr++
if cerr > 3 {
log.Log(err)
cerr = 0
}
time.Sleep(time.Second) time.Sleep(time.Second)
continue continue
} }
@ -279,9 +287,16 @@ func (c *registrySelector) run(name string) {
if c.quit() { if c.quit() {
return return
} }
log.Log(err) cerr++
if cerr > 3 {
cerr = 0
log.Log(err)
}
continue continue
} }
// reset err counter
cerr = 0
} }
} }