Skip to content

Commit 78e519e

Browse files
authored
Update kv_cache.go
1 parent 113a528 commit 78e519e

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

server/datasource/etcd/kv/kv_cache.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,25 @@ type CacheSearchReq struct {
8686
func (kc *Cache) Refresh(ctx context.Context) {
8787
openlog.Info("start to list and watch")
8888
retries := 0
89-
timer := time.NewTimer(backoff.GetBackoff().Delay(retries))
89+
90+
timer := time.NewTimer(backOffMinInterval)
9091
defer timer.Stop()
9192
for {
93+
nextPeriod := backOffMinInterval
9294
if err := kc.listWatch(ctx); err != nil {
9395
retries++
96+
nextPeriod = backoff.GetBackoff().Delay(retries)
9497
} else {
9598
retries = 0
9699
}
97-
<-timer.C
98-
timer.Reset(backoff.GetBackoff().Delay(retries))
100+
101+
select {
102+
case <-ctx.Done():
103+
openlog.Info("stop to list and watch")
104+
return
105+
case <-timer.C:
106+
timer.Reset(nextPeriod)
107+
}
99108
}
100109
}
101110

0 commit comments

Comments
 (0)