创建任务不需要验证全局锁

This commit is contained in:
Yun
2024-06-19 16:31:51 +08:00
parent 25b5008af9
commit 5ca5b31efb
+9 -9
View File
@@ -216,16 +216,16 @@ func (c *Cluster) addJob(ctx context.Context, taskId string, jobData JobData, ca
return err return err
} }
ctx, cancel := context.WithCancel(ctx) // ctx, cancel := context.WithCancel(ctx)
defer cancel() // defer cancel()
lock := lockx.NewGlobalLock(ctx, c.redis, taskId) // lock := lockx.NewGlobalLock(ctx, c.redis, taskId)
tB := lock.Try(2) // tB := lock.Try(2)
if !tB { // if !tB {
c.logger.Errorf(ctx, "添加失败:%s", taskId) // c.logger.Errorf(ctx, "添加失败:%s", taskId)
return errors.New("添加失败") // return errors.New("添加失败")
} // }
defer lock.Unlock() // defer lock.Unlock()
t := timerStr{ t := timerStr{
Callback: callback, Callback: callback,