From 015bfd8c1c7e7e6651574a2cff06852cb59cf4c2 Mon Sep 17 00:00:00 2001 From: Sydonian <794346190@qq.com> Date: Tue, 30 May 2023 16:28:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=9A=8F=E6=9C=BA=E5=90=AF=E5=8A=A8=E5=BB=B6=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/tickevent/tick_event.go | 2 ++ main.go | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/tickevent/tick_event.go b/internal/tickevent/tick_event.go index da51b6e..4620624 100644 --- a/internal/tickevent/tick_event.go +++ b/internal/tickevent/tick_event.go @@ -11,6 +11,8 @@ type ExecuteArgs struct { DB *mydb.DB } +type StartOption = tickevent.StartOption + type Executor = tickevent.Executor[ExecuteArgs] type ExecuteContext = tickevent.ExecuteContext[ExecuteArgs] diff --git a/main.go b/main.go index d47fa63..c40ad05 100644 --- a/main.go +++ b/main.go @@ -87,15 +87,15 @@ func serveScannerServer(server *scsvr.ScannerServer, wg *sync.WaitGroup) { func startTickEvent(tickExecutor *tickevent.Executor) { // TODO 可以考虑增加配置文件,配置这些任务间隔时间 - tickExecutor.Start(tickevent.NewBatchAllAgentCheckCache(), 5*60*1000) + tickExecutor.Start(tickevent.NewBatchAllAgentCheckCache(), 5*60*1000, tickevent.StartOption{RandomStartDelayMs: 60 * 1000}) - tickExecutor.Start(tickevent.NewBatchCheckAllObject(), 5*60*1000) + tickExecutor.Start(tickevent.NewBatchCheckAllObject(), 5*60*1000, tickevent.StartOption{RandomStartDelayMs: 60 * 1000}) - tickExecutor.Start(tickevent.NewBatchCheckAllRepCount(), 5*60*1000) + tickExecutor.Start(tickevent.NewBatchCheckAllRepCount(), 5*60*1000, tickevent.StartOption{RandomStartDelayMs: 60 * 1000}) - tickExecutor.Start(tickevent.NewBatchCheckAllStorage(), 5*60*1000) + tickExecutor.Start(tickevent.NewBatchCheckAllStorage(), 5*60*1000, tickevent.StartOption{RandomStartDelayMs: 60 * 1000}) - //tickExecutor.Start(tickevent.NewCheckAgentState(), 5*60*1000) + //tickExecutor.Start(tickevent.NewCheckAgentState(), 5*60*1000, tickevent.StartOption{RandomFirstStartDelayMs: 60 * 1000}) - tickExecutor.Start(tickevent.NewCheckCache(), 5*60*1000) + tickExecutor.Start(tickevent.NewCheckCache(), 5*60*1000, tickevent.StartOption{RandomStartDelayMs: 60 * 1000}) }