Documentation
¶
Overview ¶
goCron : A Golang Job Scheduling Package.
An in-process scheduler for periodic jobs that uses the builder pattern for configuration. Schedule lets you run Golang functions periodically at pre-determined intervals using a simple, human-friendly syntax.
Inspired by the Ruby module clockwork <https://github.com/tomykaira/clockwork> and Python package schedule <https://github.com/dbader/schedule>
See also http://adam.heroku.com/past/2010/4/13/rethinking_cron/ http://adam.heroku.com/past/2010/6/30/replace_cron_with_clockwork/
Copyright 2014 Jason Lyu. jasonlvhit@gmail.com . All rights reserved. Use of this source code is governed by a BSD-style . license that can be found in the LICENSE file.
Index ¶
- Constants
- func ChangeLoc(newLocation *time.Location)
- func Clear()
- func Remove(j interface{})
- func RunAll()
- func RunAllwithDelay(d int)
- func RunPending()
- func RunTasks()
- func Start() chan bool
- type Job
- func (j *Job) At(t string) *Job
- func (j *Job) Day() (job *Job)
- func (j *Job) Days() *Job
- func (j *Job) Do(jobFun interface{}, params ...interface{})
- func (j *Job) Friday() (job *Job)
- func (j *Job) Hour() (job *Job)
- func (j *Job) Hours() (job *Job)
- func (j *Job) Minute() (job *Job)
- func (j *Job) Minutes() (job *Job)
- func (j *Job) Monday() (job *Job)
- func (j *Job) NextScheduledTime() time.Time
- func (j *Job) Saturday() (job *Job)
- func (j *Job) Second() (job *Job)
- func (j *Job) Seconds() (job *Job)
- func (j *Job) Sunday() (job *Job)
- func (j *Job) Thursday() (job *Job)
- func (j *Job) Tuesday() (job *Job)
- func (j *Job) Wednesday() (job *Job)
- func (j *Job) Weeks() *Job
- type Scheduler
- func (s *Scheduler) Clear()
- func (s *Scheduler) Every(interval uint64) *Job
- func (s *Scheduler) Len() int
- func (s *Scheduler) Less(i, j int) bool
- func (s *Scheduler) NextRun() (*Job, time.Time)
- func (s *Scheduler) Remove(j interface{})
- func (s *Scheduler) RunAll()
- func (s *Scheduler) RunAllwithDelay(d int)
- func (s *Scheduler) RunPending()
- func (s *Scheduler) Start() chan bool
- func (s *Scheduler) Swap(i, j int)
Constants ¶
const MAXJOBNUM = 10000
Max number of jobs, hack it if you need.
Variables ¶
This section is empty.
Functions ¶
func RunAllwithDelay ¶
func RunAllwithDelay(d int)
Run all the jobs with a delay in seconds
A delay of `delay` seconds is added between each job. This can help to distribute the system load generated by the jobs more evenly over time.
func RunPending ¶
func RunPending()
Run all jobs that are scheduled to run
Please note that it is *intended behavior that run_pending() does not run missed jobs*. For example, if you've registered a job that should run every minute and you only call run_pending() in one hour increments then your job won't be run 60 times in between but only once.
func RunTasks ¶
func RunTasks()
RunTasks you can manage or add your tasks in the function body https://godoc.org/github.com/jasonlvhit/gocron example
Types ¶
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
func (*Job) Do ¶
func (j *Job) Do(jobFun interface{}, params ...interface{})
Specifies the jobFunc that should be called every time the job runs
func (*Job) NextScheduledTime ¶
NextScheduledTime returns the time of when this job is to run next
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Class Scheduler, the only data member is the list of jobs.
func (*Scheduler) RunAll ¶
func (s *Scheduler) RunAll()
Run all jobs regardless if they are scheduled to run or not
func (*Scheduler) RunAllwithDelay ¶
Run all jobs with delay seconds
func (*Scheduler) RunPending ¶
func (s *Scheduler) RunPending()
Run all the jobs that are scheduled to run.