大版本更新

This commit is contained in:
Yun
2024-05-20 09:35:12 +08:00
parent 0921514339
commit 7912bbc56c
7 changed files with 513 additions and 206 deletions
+19 -21
View File
@@ -7,38 +7,36 @@ import (
type timerStr struct {
Callback callback // 需要回调的方法
CanRunning chan (struct{}) // 是否允许执行
BeginTime time.Time // 初始化任务的时间
NextTime time.Time // [删]下一次执行的时间
SpaceTime time.Duration // 任务间隔时间
TaskId string // 任务ID 全局唯一键
CanRunning chan (struct{}) // 是否允许执行(only single)
TaskId string // 任务ID 全局唯一键(only cluster)
ExtendData interface{} // 附加参数
JobType JobType // 任务类型
JobData *JobData // 任务时间数据
}
type JobType string
const (
JobTypeEveryDay JobType = "every_day"
JobTypeEveryHour JobType = "every_hour"
JobTypeEveryMinute JobType = "every_minute"
JobTypeEverySecond JobType = "every_second"
JobTypeEveryMonth JobType = "every_month"
// 根据间隔时间执行
JobTypeInterval JobType = "interval"
JobTypeEveryMonth JobType = "every_month" // 每月
JobTypeEveryWeek JobType = "every_week" // 每周
JobTypeEveryDay JobType = "every_day" // 每天
JobTypeEveryHour JobType = "every_hour" // 每小时
JobTypeEveryMinute JobType = "every_minute" // 每分钟
JobTypeEverySecond JobType = "every_second" // 每秒
JobTypeInterval JobType = "interval" // 指定时间间隔
)
type JobData struct {
Month *time.Month // 每年的第几个月
Weekday *time.Weekday // 每周的周几
Day *int // 每月的第几天
Hour *int // 每天的第几个小时
Minute *int // 每小时的第几分钟
Second *int // 每分钟的第几秒
JobType JobType // 任务类型
NextTime time.Time // 下次执行时间
CreateTime time.Time // 任务创建时间
IntervalTime time.Duration // 任务间隔时间
Month time.Month // 每的第几个月
Weekday time.Weekday // 每周的周几
Day int // 每月的第几天
Hour int // 每天的第几个小时
Minute int // 每小时的第几分钟
Second int // 每分钟的第几秒
}
var nextTime = time.Now() // 下一次执行的时间
// 定义各个回调函数
type callback func(ctx context.Context, extendData interface{}) error