From f873130a20897748d29381a985df2ad468262610 Mon Sep 17 00:00:00 2001 From: Yun Date: Sat, 29 Nov 2025 22:52:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=A0=E5=85=A5=E9=97=B4=E9=9A=94=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=B0=8F=E4=BA=8E=E7=AD=89=E4=BA=8E0=E5=B0=B1?= =?UTF-8?q?=E7=AB=8B=E9=A9=AC=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- once.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/once.go b/once.go index 5aba721..36bce5a 100644 --- a/once.go +++ b/once.go @@ -349,6 +349,9 @@ func (l *Once) parseRedisKey(key string) (OnceTaskType, string, error) { // @param delayTime time.Duration 延迟时间 // @param attachData interface{} 附加数据 func (l *Once) Save(ctx context.Context, taskType OnceTaskType, taskId string, delayTime time.Duration, attachData any) error { + if delayTime < 0 { + delayTime = 0 + } execTime := time.Now().Add(delayTime) return l.save(ctx, jobTypeOnce, taskType, taskId, []time.Time{execTime}, attachData, 0) } @@ -425,8 +428,7 @@ func (w *Once) save(ctx context.Context, jobType jobType, taskType OnceTaskType, // 添加任务(不覆盖) func (l *Once) Create(ctx context.Context, taskType OnceTaskType, taskId string, delayTime time.Duration, attachData any) error { if delayTime <= 0 { - l.logger.Errorf(ctx, "delay time must be positive taskType:%v taskId:%v attachData:%v", taskType, taskId, attachData) - return ErrDelayTime + delayTime = 0 } execTime := time.Now().Add(delayTime) return l.create(ctx, jobTypeOnce, taskType, taskId, []time.Time{execTime}, attachData, 0)