From 23e3f12e881c4626af7d06336bac77e717b00bea Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Fri, 16 Feb 2024 11:29:33 +0800 Subject: [PATCH] chore: better timer using --- component/slowdown/slowdown.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/component/slowdown/slowdown.go b/component/slowdown/slowdown.go index 3fc12191a..eff4915f1 100644 --- a/component/slowdown/slowdown.go +++ b/component/slowdown/slowdown.go @@ -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() }