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, tz *time.Location)
- func (c *Cron) AddJob(spec string, cmd Job, name string, tz *time.Location)
- func (c *Cron) Entries() []Entry
- func (c *Cron) QueuingJobs() int
- func (c *Cron) RemoveJob(name string)
- func (c *Cron) RunningJobs() int
- 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 Option
- 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) QueuingJobs ¶ added in v0.0.7
func (*Cron) RunningJobs ¶ added in v0.0.7
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 NextScheduleTime 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 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 ¶
SpecSchedule specifies a duty cycle (to the second granularity), based on a traditional crontab specification. It is computed initially and stored as bit sets.