Retry send after timer fires, in case no updates occur

This commit is contained in:
freddygv 2021-02-05 18:00:59 -07:00
parent 8de6b2590c
commit 0a8f2f2105
1 changed files with 17 additions and 8 deletions

View File

@ -628,11 +628,6 @@ func (s *state) run() {
case s.snapCh <- *snapCopy:
s.logger.Trace("Delivered new snapshot to proxy config watchers")
// avoid blocking if a snapshot is already buffered
default:
s.logger.Trace("Failed to deliver new snapshot to proxy config watchers")
}
// Allow the next change to trigger a send
coalesceTimer = nil
@ -640,6 +635,20 @@ func (s *state) run() {
// this iteration
continue
// avoid blocking if a snapshot is already buffered, but queue up a retry with a timer
default:
s.logger.Trace("Failed to deliver new snapshot to proxy config watchers")
if coalesceTimer == nil {
coalesceTimer = time.AfterFunc(coalesceTimeout, func() {
sendCh <- struct{}{}
})
}
// Do not reset coalesceTimer since we just queued a timer-based refresh
continue
}
case replyCh := <-s.reqCh:
s.logger.Trace("A proxy config snapshot was requested")