From e332cc44c96624f31770af5e467c139f496c7224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Fri, 11 Aug 2023 18:29:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BB=BB=E5=8A=A1=E6=97=B6,?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E5=88=86=E9=85=8Drun=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core.go b/core.go index 97d1dc8..9c33464 100644 --- a/core.go +++ b/core.go @@ -181,9 +181,10 @@ func (tw *TimeWheel) checkAndRunTask() { // // Date : 13:43 2023/8/4 func (tw *TimeWheel) AddTask(task *Task, byInterval bool) { - if nil != task { - // 生成 key - task.Key = wrapper.StringFromRandom(128, "").Md5().Value + // 生成 run_id + task.RunID = wrapper.StringFromRandom(128, "").Md5().Value + if nil != task && nil != task.Job { + task.Key = task.Job.GetFlag() + "_" + task.RunID } var pos, circle int if byInterval { @@ -261,6 +262,7 @@ func (tw *TimeWheel) getPosAndCircleByCreatedTime(createdTime time.Time, d time. // // Date : 11:44 2023/8/4 type Task struct { + RunID string // 每一次运行的run id Key string // 用来标识task对象,是唯一的 Interval time.Duration // 任务周期 CreatedTime time.Time // 任务的创建时间