Skip to content

Commit

Permalink
chore: better timer using
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Feb 16, 2024
1 parent 985b884 commit 23e3f12
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion component/slowdown/slowdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ type SlowDown struct {
}

func (s *SlowDown) Wait(ctx context.Context) (err error) {
timer := time.NewTimer(s.backoff.Duration())
defer timer.Stop()
select {
case <-time.After(s.backoff.Duration()):
case <-timer.C:
case <-ctx.Done():
err = ctx.Err()
}
Expand Down

0 comments on commit 23e3f12

Please sign in to comment.