Documentation ¶
Index ¶
- Constants
- Variables
- func Clear()
- func Remove(j interface{})
- func RunAll()
- func RunAllwithDelay(d int)
- func RunPending()
- func Scheduled(j interface{}) bool
- func SetLocker(l Locker)
- func Start() chan bool
- type Locker
- type Scheduler
- func (s *Scheduler) ChangeLoc(newLocation *time.Location)
- func (s *Scheduler) Clear()
- func (s *Scheduler) Every(interval uint64) *Task
- func (s *Scheduler) Len() int
- func (s *Scheduler) Less(i, j int) bool
- func (s *Scheduler) NextRun() (*Task, time.Time)
- func (s *Scheduler) Remove(j interface{})
- func (s *Scheduler) RemoveByRef(j *Task)
- func (s *Scheduler) RemoveByTag(t string)
- func (s *Scheduler) RunAll()
- func (s *Scheduler) RunAllwithDelay(d int)
- func (s *Scheduler) RunPending()
- func (s *Scheduler) Scheduled(j interface{}) bool
- func (s *Scheduler) Start() chan bool
- func (s *Scheduler) Swap(i, j int)
- func (s *Scheduler) Tasks() []*Task
- type Task
- func (j *Task) At(t string) *Task
- func (j *Task) Day() *Task
- func (j *Task) Days() *Task
- func (j *Task) Do(taskFun interface{}, params ...interface{}) error
- func (j *Task) DoSafely(taskFun interface{}, params ...interface{}) error
- func (j *Task) Err() error
- func (j *Task) Friday() *Task
- func (j *Task) From(t *time.Time) *Task
- func (j *Task) GetAt() string
- func (j *Task) GetWeekday() time.Weekday
- func (j *Task) Hour() *Task
- func (j *Task) Hours() *Task
- func (j *Task) Loc(loc *time.Location) *Task
- func (j *Task) Lock() *Task
- func (j *Task) Minute() *Task
- func (j *Task) Minutes() *Task
- func (j *Task) Monday() (job *Task)
- func (j *Task) NextScheduledTime() time.Time
- func (j *Task) Saturday() *Task
- func (j *Task) Second() *Task
- func (j *Task) Seconds() *Task
- func (j *Task) Sunday() *Task
- func (j *Task) Tag(t string, others ...string)
- func (j *Task) Tags() []string
- func (j *Task) Thursday() *Task
- func (j *Task) Tuesday() *Task
- func (j *Task) Untag(t string)
- func (j *Task) Wednesday() *Task
- func (j *Task) Week() *Task
- func (j *Task) Weekday(startDay time.Weekday) *Task
- func (j *Task) Weeks() *Task
Constants ¶
const MAXJOBNUM = 1000
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 parameters cannot be used with reflection") )
Functions ¶
func RunAllwithDelay ¶
func RunAllwithDelay(d int)
RunAllwithDelay 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()
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.
Types ¶
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler struct, the only data member is the list of jobs.
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 ¶
RemoveByTag removes specific job j by tag
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) RunPending ¶
func (s *Scheduler) RunPending()
RunPending runs all the jobs that are scheduled to run.
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task struct keeping information about job
func (*Task) At ¶
At schedules job at specific time of day
s.Every(1).Day().At("10:30:01").Do(task) s.Every(1).Monday().At("10:30:01").Do(task)
func (*Task) 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 (*Task) GetAt ¶
GetAt returns the specific time of day the job will run at
s.Every(1).Day().At("10:30").GetAt() == "10:30"
func (*Task) GetWeekday ¶
GetWeekday returns which day of the week the job will run on This should only be used when .Weekday(...) was called on the job.
func (*Task) Loc ¶
Loc sets the location for which to interpret "At"
s.Every(1).Day().At("10:30").Loc(time.UTC).Do(task)
func (*Task) NextScheduledTime ¶
NextScheduledTime returns the time of when this job is to run next
func (*Task) Tag ¶
Tag allows you to add labels to a job they don't impact the functionality of the job.