Documentation ¶
Overview ¶
This library implements a cron spec parser and runner. See the README for more details.
Index ¶
- type ConstantDelaySchedule
- type Cron
- func (c *Cron) AddFunc(spec string, cmd func(), name string)
- func (c *Cron) AddJob(spec string, cmd Job, name string)
- func (c *Cron) AddOnceFunc(time time.Time, cmd func(), name string)
- func (c *Cron) AddOnceJob(time time.Time, cmd Job, name string)
- func (c *Cron) Entries() []*Entry
- func (c *Cron) RemoveJob(name string)
- func (c *Cron) Schedule(schedule Schedule, cmd Job, name string)
- func (c *Cron) Start()
- func (c *Cron) Stop()
- type Entry
- type FuncJob
- type Job
- type OnceSchedule
- type Schedule
- type SpecSchedule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConstantDelaySchedule ¶
ConstantDelaySchedule represents a simple recurring duty cycle, e.g. "Every 5 minutes". It does not support jobs more frequent than once a second.
func Every ¶
func Every(duration time.Duration) ConstantDelaySchedule
Every returns a crontab Schedule that activates once every duration. Delays of less than a second are not supported (will panic). Any fields less than a Second are truncated.
type Cron ¶
type Cron struct {
// contains filtered or unexported fields
}
Cron keeps track of any number of entries, invoking the associated func as specified by the schedule. It may be started, stopped, and the entries may be inspected while running.
func (*Cron) AddOnceJob ¶
AddFunc adds a Job to the Cron to be run on the given schedule.
type Entry ¶
type Entry struct { // The schedule on which this job should be run. Schedule Schedule // The next time the job will run. This is the zero time if Cron has not been // started or this entry's schedule is unsatisfiable Next time.Time // The last time this job was run. This is the zero time if the job has never // been run. Prev time.Time // The Job to run. Job Job // Unique name to identify the Entry so as to be able to remove it later. Name string }
Entry consists of a schedule and the func to execute on that schedule.
type OnceSchedule ¶
type OnceSchedule struct {
// contains filtered or unexported fields
}
func CreateOnceSchedule ¶
func CreateOnceSchedule(time time.Time) *OnceSchedule
func (*OnceSchedule) Done ¶
func (schedule *OnceSchedule) Done()
type Schedule ¶
type Schedule interface { // Return the next activation time, later than the given time. // Next is invoked initially, and then each time the job is run. Next(time.Time) time.Time }
The Schedule describes a job's duty cycle.
type SpecSchedule ¶
type SpecSchedule struct {
Second, Minute, Hour, Dom, Month, Dow uint64
}
SpecSchedule specifies a duty cycle (to the second granularity), based on a traditional crontab specification. It is computed initially and stored as bit sets.