chore: better timer using

This commit is contained in:
wwqgtxx 2024-02-16 11:29:33 +08:00
parent 985b884d85
commit 23e3f12e88

View File

@ -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()
}