Skip to content

Commit

Permalink
naming is hard
Browse files Browse the repository at this point in the history
  • Loading branch information
vdarulis committed Dec 14, 2020
1 parent c4a7384 commit 654274e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/cluster/etcd/watchmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ func (w *manager) Watch(key string) {
logger = w.logger.With(zap.String("watch_key", key))
rnd = rand.New(rand.NewSource(time.Now().UnixNano())) //nolint:gosec

revOverride int64
watchInitialized bool
watchChan clientv3.WatchChan
cancelFn context.CancelFunc
err error
revOverride int64
firstUpdateSucceeded bool
watchChan clientv3.WatchChan
cancelFn context.CancelFunc
err error
)

defer ticker.Stop()
Expand All @@ -153,13 +153,13 @@ func (w *manager) Watch(key string) {

// NB(cw) when we failed to create a etcd watch channel
// we do a get for now and will try to recreate the watch chan later
if !watchInitialized {
if !firstUpdateSucceeded {
if err = w.updateFn(key, nil); err != nil {
logger.Error("failed to get value for key", zap.Error(err))
} else {
// NB(vytenis): only try initializing once, otherwise there's
// get request amplification, especially for non-existent keys.
watchInitialized = true
firstUpdateSucceeded = true
}
}
resetWatchWithSleep()
Expand Down

0 comments on commit 654274e

Please sign in to comment.