Documentation ¶
Index ¶
- type GoJob
- func (o *GoJob) Cron() gocron.Scheduler
- func (c *GoJob) CronJob(spec string, options *[]gocron.JobOption, function any, parameters ...any) (gocron.Job, error)
- func (c *GoJob) DailyJob(options *[]gocron.JobOption, interval uint, hours []uint, minute uint, fn any, ...) (gocron.Job, error)
- func (c *GoJob) Day(options *[]gocron.JobOption, fn any, parameters ...any) (gocron.Job, error)
- func (c *GoJob) DayHour(options *[]gocron.JobOption, hour int, fn any, parameters ...any) (gocron.Job, error)
- func (c *GoJob) DayHourMinute(options *[]gocron.JobOption, hour, minute int, fn any, parameters ...any) (gocron.Job, error)
- func (c *GoJob) DurationJob(options *[]gocron.JobOption, seconds int, fn any, parameters ...any) (gocron.Job, error)
- func (c *GoJob) DurationRandomJob(options *[]gocron.JobOption, minDuration, maxDuration time.Duration, ...) (gocron.Job, error)
- func (c *GoJob) Hour(options *[]gocron.JobOption, fn any, parameters ...any) (gocron.Job, error)
- func (c *GoJob) HourX(options *[]gocron.JobOption, x int, fn any, parameters ...any) (gocron.Job, error)
- func (c *GoJob) Minute(options *[]gocron.JobOption, fn any, parameters ...any) (gocron.Job, error)
- func (c *GoJob) MinuteX(options *[]gocron.JobOption, x int, fn any, parameters ...any) (gocron.Job, error)
- func (c *GoJob) MonthlyJob(options *[]gocron.JobOption, interval uint, daysOfTheMonth []int, hours []uint, ...) (gocron.Job, error)
- func (c *GoJob) NewJob(jobDefinition gocron.JobDefinition, task gocron.Task, ...) (gocron.Job, error)
- func (c *GoJob) OneTimeJobForMinute(options *[]gocron.JobOption, minute uint, fn any, parameters ...any) (gocron.Job, error)
- func (c *GoJob) OneTimeJobForSeconds(options *[]gocron.JobOption, seconds uint, fn any, parameters ...any) (gocron.Job, error)
- func (c *GoJob) RemoveJob(jobID uuid.UUID) error
- func (c *GoJob) Second(options *[]gocron.JobOption, fn any, parameters ...any) (gocron.Job, error)
- func (c *GoJob) SecondX(options *[]gocron.JobOption, x int, fn any, parameters ...any) (gocron.Job, error)
- func (c *GoJob) Start()
- func (c *GoJob) Stop() error
- func (c *GoJob) WeeklyJob(options *[]gocron.JobOption, interval uint, daysOfTheWeek []time.Weekday, ...) (gocron.Job, error)
- func (c *GoJob) WithStartAt(start time.Time) gocron.JobOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GoJob ¶ added in v1.1.7
type GoJob struct {
// contains filtered or unexported fields
}
func (*GoJob) CronJob ¶ added in v1.1.7
func (c *GoJob) CronJob(spec string, options *[]gocron.JobOption, function any, parameters ...any) (gocron.Job, error)
spec is crontab pattern crontab 表达式
func (*GoJob) DailyJob ¶ added in v1.1.7
func (c *GoJob) DailyJob(options *[]gocron.JobOption, interval uint, hours []uint, minute uint, fn any, parameters ...any) (gocron.Job, error)
每天定时执行
func (*GoJob) DayHour ¶ added in v1.1.7
func (c *GoJob) DayHour(options *[]gocron.JobOption, hour int, fn any, parameters ...any) (gocron.Job, error)
crontab 每天x点0分0秒执行
func (*GoJob) DayHourMinute ¶ added in v1.1.7
func (c *GoJob) DayHourMinute(options *[]gocron.JobOption, hour, minute int, fn any, parameters ...any) (gocron.Job, error)
crontab 每天x点x分0秒执行
func (*GoJob) DurationJob ¶ added in v1.1.7
func (c *GoJob) DurationJob(options *[]gocron.JobOption, seconds int, fn any, parameters ...any) (gocron.Job, error)
隔多少秒执行
func (*GoJob) DurationRandomJob ¶ added in v1.1.7
func (c *GoJob) DurationRandomJob(options *[]gocron.JobOption, minDuration, maxDuration time.Duration, function any, parameters ...any) (gocron.Job, error)
DurationRandomJob 定义一个新作业,该作业以提供的最小和最大持续时间值之间的随机间隔运行
func (*GoJob) HourX ¶ added in v1.1.7
func (c *GoJob) HourX(options *[]gocron.JobOption, x int, fn any, parameters ...any) (gocron.Job, error)
crontab 每隔x小时执行
func (*GoJob) MinuteX ¶ added in v1.1.7
func (c *GoJob) MinuteX(options *[]gocron.JobOption, x int, fn any, parameters ...any) (gocron.Job, error)
crontab 每隔x分钟执行
func (*GoJob) MonthlyJob ¶ added in v1.1.7
func (c *GoJob) MonthlyJob(options *[]gocron.JobOption, interval uint, daysOfTheMonth []int, hours []uint, minute uint, fn any, parameters ...any) (gocron.Job, error)
interval 月频, 0-6-->周日 周一 ... 周六, hours 具体执行时间列表
func (*GoJob) OneTimeJobForMinute ¶ added in v1.1.7
func (c *GoJob) OneTimeJobForMinute(options *[]gocron.JobOption, minute uint, fn any, parameters ...any) (gocron.Job, error)
当前时间 minute 分钟之后执行一次
func (*GoJob) OneTimeJobForSeconds ¶ added in v1.1.7
func (c *GoJob) OneTimeJobForSeconds(options *[]gocron.JobOption, seconds uint, fn any, parameters ...any) (gocron.Job, error)
当前时间 seconds 秒之后执行一次
func (*GoJob) SecondX ¶ added in v1.1.7
func (c *GoJob) SecondX(options *[]gocron.JobOption, x int, fn any, parameters ...any) (gocron.Job, error)
crontab 每隔x秒执行
func (*GoJob) WeeklyJob ¶ added in v1.1.7
func (c *GoJob) 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 (*GoJob) WithStartAt ¶ added in v1.1.7
在某一时刻运行 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()
定时执行启动 开始时间
Click to show internal directories.
Click to hide internal directories.