Documentation
¶
Index ¶
Constants ¶
const ( Daily = 'd' Weekly = 'w' Monthly = 'm' )
Variables ¶
var ZeroTrigger = &zeroTrigger{}
Functions ¶
Types ¶
type Cron ¶ added in v1.2.3
type Cron struct {
// contains filtered or unexported fields
}
Cron a cron expression parser and time calculator ┌───────────── second (0-59) (omittable) │ ┌───────────── minute (0-59) │ │ ┌───────────── hour (0-23) │ │ │ ┌───────────── day of the month (1-31, 32: last day of month) │ │ │ │ ┌───────────── month (1-12) │ │ │ │ │ ┌───────────── day of the week (0-6) (Sunday to Saturday; 7 is also Sunday) │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ * * * * * * Comma ( , ): used to separate items of a list. For example, "MON,WED,FRI". Dash ( - ) : used to define ranges. For example, "1-10" Slash (/) : combined with ranges to specify step values. For example, */5 in the minutes field indicates every 5 minutes It is shorthand for the more verbose POSIX form "5,10,15,20,25,30,35,40,45,50,55,00"
func (*Cron) Next ¶ added in v1.2.3
Next get the next time in the sequence matching the Cron pattern and after the value provided. The return value will have a whole number of seconds, and will be after the input value. @param date a seed value @return the next value matching the pattern
type CronTrigger ¶
type CronTrigger struct {
// contains filtered or unexported fields
}
func NewCronTrigger ¶
func NewCronTrigger(expr string, location ...*time.Location) (*CronTrigger, error)
func (*CronTrigger) Cron ¶ added in v1.2.3
func (ct *CronTrigger) Cron() string
func (*CronTrigger) NextExecutionTime ¶
func (ct *CronTrigger) NextExecutionTime(task *Task) time.Time
type DelayedTrigger ¶
func (*DelayedTrigger) NextExecutionTime ¶
func (dt *DelayedTrigger) NextExecutionTime(task *Task) time.Time
type Periodic ¶ added in v1.2.3
type Periodic struct {
// contains filtered or unexported fields
}
Periodic a periodic expression parser ┌───────────── unit (d: daily, w: weekly, m: monthly) │ ┌───────────── day (daily: 0, weekly: 1-7 monday to sunday, monthly: 1-31,32 is last day of month) │ │ ┌───────────── hour (0 - 23) │ │ │ * * * Comma ( , ): used to separate items of a list. For example, "MON,WED,FRI". Dash ( - ) : used to define ranges. For example, "1-10"
func ParsePeriodic ¶ added in v1.2.3
ParsePeriodic parses a periodic expression.
type PeriodicTrigger ¶
type PeriodicTrigger struct {
// contains filtered or unexported fields
}
func NewPeriodicTrigger ¶ added in v1.2.3
func NewPeriodicTrigger(periodic string, location ...*time.Location) (*PeriodicTrigger, error)
func (*PeriodicTrigger) Cron ¶ added in v1.2.3
func (pt *PeriodicTrigger) Cron() string
func (*PeriodicTrigger) NextExecutionTime ¶
func (pt *PeriodicTrigger) NextExecutionTime(task *Task) time.Time
func (*PeriodicTrigger) Periodic ¶ added in v1.2.3
func (pt *PeriodicTrigger) Periodic() string
type RepeatTrigger ¶ added in v1.2.3
func (*RepeatTrigger) NextExecutionTime ¶ added in v1.2.3
func (rt *RepeatTrigger) NextExecutionTime(task *Task) time.Time
type Scheduler ¶
Scheduler task scheduler
func Default ¶
func Default() *Scheduler
Default returns the default Scheduler instance used by the package-level functions.
func (*Scheduler) RemoveTask ¶ added in v1.2.3
RemoveTask remove a task by name Returns the removed task and whether it was found.
type Task ¶
type Task struct {
Name string
Logger log.Logger
Trigger Trigger
Callback func()
ScheduledTime time.Time
ExecutionTime time.Time
CompletionTime time.Time
Error any
// contains filtered or unexported fields
}