优化RPC调用

This commit is contained in:
GoEdgeLab
2020-11-15 11:58:08 +08:00
parent 332632ab9f
commit 22ce8bcef5
2 changed files with 19 additions and 8 deletions

View File

@@ -53,6 +53,7 @@ func (this *IPListManager) Start() {
events.On(events.EventQuit, func() {
ticker.Stop()
})
countErrors := 0
for {
select {
case <-ticker.C:
@@ -60,14 +61,19 @@ func (this *IPListManager) Start() {
}
err := this.loop()
if err != nil {
countErrors++
logs.Println("IP_LIST_MANAGER", err.Error())
// 方便立即重试
select {
case IPListUpdateNotify <- true:
default:
// 连续错误小于3次的我们立即重试
if countErrors <= 3 {
select {
case IPListUpdateNotify <- true:
default:
}
}
} else {
countErrors = 0
}
}
}