Documentation ¶
Overview ¶
Package scheduler is a cron replacement based on:
http://adam.herokuapp.com/past/2010/4/13/rethinking_cron/
and
https://github.com/dbader/schedule
Uses include:
func main() { job := func() { fmt.Println("Time's up!") } scheduler.Every(5).Seconds().Run(function) scheduler.Every().Day().Run(function) scheduler.Every().Sunday().At("08:30").Run(function) }
Index ¶
- type Job
- func (j *Job) At(hourTime string) *Job
- func (j *Job) Day() *Job
- func (j *Job) Friday() *Job
- func (j *Job) Hours() *Job
- func (j *Job) IsRunning() bool
- func (j *Job) Minutes() *Job
- func (j *Job) Monday() *Job
- func (j *Job) NotImmediately() *Job
- func (j *Job) Run(f func()) (*Job, error)
- func (j *Job) Saturday() *Job
- func (j *Job) Seconds() *Job
- func (j *Job) Sunday() *Job
- func (j *Job) Thursday() *Job
- func (j *Job) Tuesday() *Job
- func (j *Job) Wednesday() *Job
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct { Quit chan bool SkipWait chan bool sync.RWMutex // contains filtered or unexported fields }
Job defines a running job and allows to stop a scheduled job or run it.
func Every ¶
Every defines when to run a job. For a recurrent jobs (n seconds/minutes/hours) you should specify the unit and then call to the correspondent period method.
func (*Job) At ¶
At lets you define a specific time when the job would be run. Does not work with recurrent jobs. Time should be defined as a string separated by a colon. Could be used as "08:35:30", "08:35" or "8" for only the hours.
func (*Job) Hours ¶
Hours sets the job to run every n Hours where n was defined in the Every function.
func (*Job) Minutes ¶
Minutes sets the job to run every n Minutes where n was defined in the Every function.
func (*Job) NotImmediately ¶
NotImmediately allows recurrent jobs not to be executed immediatelly after definition. If a job is declared hourly won't start executing until the first hour passed.
func (*Job) Run ¶
Run sets the job to the schedule and returns the pointer to the job so it may be stopped or executed without waiting or an error.