From cad8958c8f5f1310c28b103ed7e0677d4fc1be3e Mon Sep 17 00:00:00 2001 From: Sydonian <794346190@qq.com> Date: Tue, 30 May 2023 17:09:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=B0=83=E8=AF=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/tickevent/executor.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/tickevent/executor.go b/pkg/tickevent/executor.go index 62ed490..0bb0a22 100644 --- a/pkg/tickevent/executor.go +++ b/pkg/tickevent/executor.go @@ -1,6 +1,7 @@ package tickevent import ( + "math/rand" "sync/atomic" "time" ) @@ -48,7 +49,7 @@ func (e *Executor[TArgs]) Start(event TickEvent[TArgs], intervalMs int, opts ... go func() { if opt.RandomStartDelayMs > 0 { - <-time.After(time.Duration(opt.RandomStartDelayMs) * time.Millisecond) + <-time.After(time.Duration(rand.Intn(opt.RandomStartDelayMs)) * time.Millisecond) } timeTicker := time.NewTicker(time.Duration(intervalMs) * time.Millisecond)