Documentation
¶
Overview ¶
Package 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 ¶
- Variables
- type Job
- func (j *Job) Do(jobFun interface{}, params ...interface{}) error
- func (j *Job) DoSafely(jobFun interface{}, params ...interface{}) error
- func (j *Job) Err() error
- func (j *Job) From(t time.Time) *Job
- func (j *Job) FromMidNight() *Job
- func (j *Job) Immediately() *Job
- func (j *Job) NextScheduledTime() time.Time
- func (j *Job) Once() *Job
- func (j *Job) SetTags(tags ...string)
- func (j *Job) Tags() []string
- func (j *Job) Untag(t string)
- type Scheduler
- func (s *Scheduler) Clear()
- func (s *Scheduler) Every(interval time.Duration) *Job
- func (s *Scheduler) Jobs() []*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) RemoveByRef(j *Job)
- func (s *Scheduler) RemoveByTag(tag string)
- func (s *Scheduler) RunAll()
- func (s *Scheduler) RunAllwithDelay(d time.Duration)
- func (s *Scheduler) Scheduled(j interface{}) bool
- func (s *Scheduler) Start()
- func (s *Scheduler) StartAsync() chan struct{}
- func (s *Scheduler) Stop()
- func (s *Scheduler) Swap(i, j int)
Constants ¶
This section is empty.
Variables ¶
var ( ErrTimeFormat = errors.New("time format error") ErrParamsNotAdapted = errors.New("the number of params is not adapted") ErrNotAFunction = errors.New("only functions can be schedule into the job queue") ErrPeriodNotSpecified = errors.New("unspecified job period") ErrParameterCannotBeNil = errors.New("nil paramaters cannot be used with reflection") )
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job struct keeping information about job
func (*Job) DoSafely ¶
DoSafely does the same thing as Do, but logs unexpected panics, instead of unwinding them up the chain Deprecated: DoSafely exists due to historical compatibility and will be removed soon. Use Do instead
func (*Job) FromMidNight ¶
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
}
Scheduler struct, the only data member is the list of jobs. - implements the sort.Interface{} for sorting jobs, by the time nextRun
func (*Scheduler) Remove ¶
func (s *Scheduler) Remove(j interface{})
Remove specific job j by function
func (*Scheduler) RemoveByRef ¶
RemoveByRef removes specific job j by reference
func (*Scheduler) RemoveByTag ¶
func (*Scheduler) RunAll ¶
func (s *Scheduler) RunAll()
RunAll run all jobs regardless if they are scheduled to run or not
func (*Scheduler) RunAllwithDelay ¶
RunAllwithDelay runs all jobs with delay seconds
func (*Scheduler) StartAsync ¶
func (s *Scheduler) StartAsync() chan struct{}