添加任务时, 增加分配run id

This commit is contained in:
zhangdeman committed 2023-08-11 18:29:00 +08:00
1 parent a96cf04261
commit e332cc44c9
1 file changed
+5 -3
+5 -3
View File
@@ -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 // 任务的创建时间
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.