Documentation ¶
Index ¶
- type CronsModel
- func (o *CronsModel) Cron() gocron.Scheduler
- func (c *CronsModel) CronJob(spec string, options *[]gocron.JobOption, function any, parameters ...any) (gocron.Job, error)
- func (c *CronsModel) DailyJob(options *[]gocron.JobOption, interval uint, hours []uint, minute uint, fn any, ...) (gocron.Job, error)
- func (c *CronsModel) Day(options *[]gocron.JobOption, fn any, parameters ...any) (gocron.Job, error)
- func (c *CronsModel) DayHour(options *[]gocron.JobOption, hour int, fn any, parameters ...any) (gocron.Job, error)
- func (c *CronsModel) DayHourMinute(options *[]gocron.JobOption, hour, minute int, fn any, parameters ...any) (gocron.Job, error)
- func (c *CronsModel) DurationJob(options *[]gocron.JobOption, seconds int, fn any, parameters ...any) (gocron.Job, error)
- func (c *CronsModel) DurationRandomJob(options *[]gocron.JobOption, minDuration, maxDuration time.Duration, ...) (gocron.Job, error)
- func (c *CronsModel) Hour(options *[]gocron.JobOption, fn any, parameters ...any) (gocron.Job, error)
- func (c *CronsModel) HourX(options *[]gocron.JobOption, x int, fn any, parameters ...any) (gocron.Job, error)
- func (c *CronsModel) Minute(options *[]gocron.JobOption, fn any, parameters ...any) (gocron.Job, error)
- func (c *CronsModel) MinuteX(options *[]gocron.JobOption, x int, fn any, parameters ...any) (gocron.Job, error)
- func (c *CronsModel) MonthlyJob(options *[]gocron.JobOption, interval uint, daysOfTheMonth []int, hours []uint, ...) (gocron.Job, error)
- func (c *CronsModel) OneTimeJobForMinute(options *[]gocron.JobOption, minute uint, fn any, parameters ...any) (gocron.Job, error)
- func (c *CronsModel) OneTimeJobForSeconds(options *[]gocron.JobOption, seconds uint, fn any, parameters ...any) (gocron.Job, error)
- func (c *CronsModel) RemoveJob(jobID uuid.UUID) error
- func (c *CronsModel) Second(options *[]gocron.JobOption, fn any, parameters ...any) (gocron.Job, error)
- func (c *CronsModel) SecondX(options *[]gocron.JobOption, x int, fn any, parameters ...any) (gocron.Job, error)
- func (c *CronsModel) Start()
- func (c *CronsModel) Stop() error
- func (c *CronsModel) WeeklyJob(options *[]gocron.JobOption, interval uint, daysOfTheWeek []time.Weekday, ...) (gocron.Job, error)
- func (c *CronsModel) WithStartAt(start time.Time) gocron.JobOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CronsModel ¶
type CronsModel struct {
// contains filtered or unexported fields
}
func New ¶
func New(options ...gocron.SchedulerOption) (*CronsModel, error)
func (*CronsModel) Cron ¶
func (o *CronsModel) Cron() gocron.Scheduler
func (*CronsModel) CronJob ¶ added in v1.1.2
func (c *CronsModel) CronJob(spec string, options *[]gocron.JobOption, function any, parameters ...any) (gocron.Job, error)
spec is crontab pattern crontab 表达式
func (*CronsModel) DailyJob ¶ added in v1.1.2
func (c *CronsModel) DailyJob(options *[]gocron.JobOption, interval uint, hours []uint, minute uint, fn any, parameters ...any) (gocron.Job, error)
每天定时执行
func (*CronsModel) Day ¶
func (c *CronsModel) Day(options *[]gocron.JobOption, fn any, parameters ...any) (gocron.Job, error)
crontab 每天0点0分0秒执行
func (*CronsModel) DayHour ¶
func (c *CronsModel) DayHour(options *[]gocron.JobOption, hour int, fn any, parameters ...any) (gocron.Job, error)
crontab 每天x点0分0秒执行
func (*CronsModel) DayHourMinute ¶
func (c *CronsModel) DayHourMinute(options *[]gocron.JobOption, hour, minute int, fn any, parameters ...any) (gocron.Job, error)
crontab 每天x点x分0秒执行
func (*CronsModel) DurationJob ¶ added in v1.1.2
func (c *CronsModel) DurationJob(options *[]gocron.JobOption, seconds int, fn any, parameters ...any) (gocron.Job, error)
隔多少秒执行 , 可以通过 gocron.WithSingletonMode(gocron.LimitModeWait)来限制重叠执行
func (*CronsModel) DurationRandomJob ¶ added in v1.1.2
func (c *CronsModel) DurationRandomJob(options *[]gocron.JobOption, minDuration, maxDuration time.Duration, function any, parameters ...any) (gocron.Job, error)
DurationRandomJob 定义一个新作业,该作业以提供的最小和最大持续时间值之间的随机间隔运行
func (*CronsModel) Hour ¶
func (c *CronsModel) Hour(options *[]gocron.JobOption, fn any, parameters ...any) (gocron.Job, error)
crontab 每小时执行
func (*CronsModel) HourX ¶
func (c *CronsModel) HourX(options *[]gocron.JobOption, x int, fn any, parameters ...any) (gocron.Job, error)
crontab 每隔x小时执行
func (*CronsModel) Minute ¶
func (c *CronsModel) Minute(options *[]gocron.JobOption, fn any, parameters ...any) (gocron.Job, error)
crontab 每分钟执行
func (*CronsModel) MinuteX ¶
func (c *CronsModel) MinuteX(options *[]gocron.JobOption, x int, fn any, parameters ...any) (gocron.Job, error)
crontab 每隔x分钟执行
func (*CronsModel) MonthlyJob ¶ added in v1.1.2
func (c *CronsModel) MonthlyJob(options *[]gocron.JobOption, interval uint, daysOfTheMonth []int, hours []uint, minute uint, fn any, parameters ...any) (gocron.Job, error)
interval 月频, 0-6-->周日 周一 ... 周六, hours 具体执行时间列表
func (*CronsModel) OneTimeJobForMinute ¶ added in v1.1.2
func (c *CronsModel) OneTimeJobForMinute(options *[]gocron.JobOption, minute uint, fn any, parameters ...any) (gocron.Job, error)
当前时间 minute 分钟之后执行一次
func (*CronsModel) OneTimeJobForSeconds ¶ added in v1.1.2
func (c *CronsModel) OneTimeJobForSeconds(options *[]gocron.JobOption, seconds uint, fn any, parameters ...any) (gocron.Job, error)
当前时间 seconds 秒之后执行一次
func (*CronsModel) RemoveJob ¶ added in v1.1.4
func (c *CronsModel) RemoveJob(jobID uuid.UUID) error
func (*CronsModel) Second ¶
func (c *CronsModel) Second(options *[]gocron.JobOption, fn any, parameters ...any) (gocron.Job, error)
crontab 每秒钟执行
func (*CronsModel) SecondX ¶
func (c *CronsModel) SecondX(options *[]gocron.JobOption, x int, fn any, parameters ...any) (gocron.Job, error)
crontab 每隔x秒执行
func (*CronsModel) Start ¶
func (c *CronsModel) Start()
func (*CronsModel) Stop ¶
func (c *CronsModel) Stop() error
func (*CronsModel) WeeklyJob ¶ added in v1.1.2
func (c *CronsModel) WeeklyJob(options *[]gocron.JobOption, interval uint, daysOfTheWeek []time.Weekday, hours []uint, minutes uint, fn any, parameters ...any) (gocron.Job, error)
interval 周频, 0-6-->周日 周一 ... 周六, hours 具体执行时间列表
func (*CronsModel) WithStartAt ¶ added in v1.1.4
func (c *CronsModel) WithStartAt(start time.Time) gocron.JobOption
在某一时刻运行 s, _ := NewScheduler() defer func() { _ = s.Shutdown() }()
start := time.Date(9999, 9, 9, 9, 9, 9, 9, time.UTC)
j, _ := s.NewJob(
DurationJob( time.Second, ), NewTask( func(one string, two int) { fmt.Printf("%s, %d", one, two) }, "one", 2, ), WithStartAt( WithStartDateTime(start), ),
) s.Start()
next, _ := j.NextRun() fmt.Println(next)
_ = s.StopJobs()
定时执行启动 开始时间