Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion notifications/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,17 @@ func (m *Manager) Run(ctx context.Context) error {
waitTime time.Duration
backoff time.Duration
attempts int
timer = time.NewTimer(0)
)

// Start the notification runloop.
for {
// Increase the wait time for the next iteration.
backoff = waitTime + time.Duration(attempts)*time.Second
waitTime = 0
timer := time.NewTimer(backoff)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need the waitTime = 0 above here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to reset the waitTime here which is really used in line 224 if we were able to connect the stream but upon first read it disconnected.

// Reset the timer with the new backoff time.
timer.Reset(backoff)

// Return if the context has been canceled.
select {
Expand All @@ -179,6 +182,10 @@ func (m *Manager) Run(ctx context.Context) error {
log.Errorf("Error getting L402 from "+
"the store: %v", err)
}

// Use a default of 1 second wait time to avoid
// hogging the CPU.
waitTime = time.Second
continue
}

Expand Down
Loading