Documentation ¶
Index ¶
- Variables
- func SetLocker(l Locker)
- type Job
- type Locker
- type Scheduler
- func (s *Scheduler) At(t string) *Scheduler
- func (s *Scheduler) ChangeLocation(newLocation *time.Location)
- func (s *Scheduler) Clear()
- func (s *Scheduler) Day() *Scheduler
- func (s *Scheduler) Days() *Scheduler
- func (s *Scheduler) Do(jobFun interface{}, params ...interface{}) (*Job, error)
- func (s *Scheduler) Every(interval uint64) *Scheduler
- func (s *Scheduler) Friday() *Scheduler
- func (s *Scheduler) Hour() *Scheduler
- func (s *Scheduler) Hours() *Scheduler
- func (s *Scheduler) Jobs() []*Job
- func (s *Scheduler) Len() int
- func (s *Scheduler) Less(i, j int) bool
- func (s *Scheduler) Lock() *Scheduler
- func (s *Scheduler) Minute() *Scheduler
- func (s *Scheduler) Minutes() *Scheduler
- func (s *Scheduler) Monday() *Scheduler
- func (s *Scheduler) Month(dayOfTheMonth int) *Scheduler
- func (s *Scheduler) Months(dayOfTheMonth int) *Scheduler
- func (s *Scheduler) NextRun() (*Job, time.Time)
- func (s *Scheduler) Remove(j interface{})
- func (s *Scheduler) RemoveByReference(j *Job)
- func (s *Scheduler) RemoveJobByTag(tag string) error
- func (s *Scheduler) Run() error
- func (s *Scheduler) RunAll()
- func (s *Scheduler) RunAllWithDelay(d int)
- func (s *Scheduler) RunPending()
- func (s *Scheduler) Saturday() *Scheduler
- func (s *Scheduler) Scheduled(j interface{}) bool
- func (s *Scheduler) Second() *Scheduler
- func (s *Scheduler) Seconds() *Scheduler
- func (s *Scheduler) SetTag(t []string) *Scheduler
- func (s *Scheduler) StartAsync() chan struct{}
- func (s *Scheduler) StartAt(t time.Time) *Scheduler
- func (s *Scheduler) StartBlocking()
- func (s *Scheduler) StartImmediately() *Scheduler
- func (s *Scheduler) Stop() error
- func (s *Scheduler) Sunday() *Scheduler
- func (s *Scheduler) Swap(i, j int)
- func (s *Scheduler) Thursday() *Scheduler
- func (s *Scheduler) Tuesday() *Scheduler
- func (s *Scheduler) Wednesday() *Scheduler
- func (s *Scheduler) Week() *Scheduler
- func (s *Scheduler) Weekday(startDay time.Weekday) *Scheduler
- func (s *Scheduler) Weeks() *Scheduler
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") ErrNotScheduledWeekday = errors.New("job not scheduled weekly on a weekday") ErrJobNotFoundWithTag = errors.New("no jobs found with given tag") ErrUnsupportedTimeFormat = errors.New("the given time format is not supported") )
Error declarations for gocron related errors
Functions ¶
Types ¶
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job struct stores the information necessary to run a Job
func (*Job) ScheduledAtTime ¶ added in v1.1.2
ScheduledAtTime returns the specific time of day the Job will run at
func (*Job) ScheduledTime ¶ added in v1.1.2
ScheduledTime returns the time of the Job's next scheduled run
func (*Job) Tag ¶ added in v1.1.2
Tag allows you to add arbitrary labels to a Job that do not impact the functionality of the Job
type Locker ¶ added in v1.1.2
Locker provides an interface for implementing job locking to prevent jobs from running at the same time on multiple instances of gocron
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler struct stores a list of Jobs and the location of time Scheduler Scheduler implements the sort.Interface{} for sorting Jobs, by the time of nextRun
func NewScheduler ¶
NewScheduler creates a new Scheduler
func (*Scheduler) At ¶ added in v1.1.2
At schedules the Job at a specific time of day in the form "HH:MM:SS" or "HH:MM"
func (*Scheduler) ChangeLocation ¶ added in v1.1.2
ChangeLocation changes the default time location
func (*Scheduler) Clear ¶ added in v1.1.2
func (s *Scheduler) Clear()
Clear clear all Jobs from this scheduler
func (*Scheduler) Do ¶ added in v1.1.2
Do specifies the jobFunc that should be called every time the Job runs
func (*Scheduler) Remove ¶ added in v1.1.2
func (s *Scheduler) Remove(j interface{})
Remove specific Job j by function
func (*Scheduler) RemoveByReference ¶ added in v1.1.2
RemoveByReference removes specific Job j by reference
func (*Scheduler) RemoveJobByTag ¶ added in v1.1.2
RemoveJobByTag will Remove Jobs by Tag
func (*Scheduler) RunAll ¶ added in v1.1.2
func (s *Scheduler) RunAll()
RunAll run all Jobs regardless if they are scheduled to run or not
func (*Scheduler) RunAllWithDelay ¶ added in v1.1.2
RunAllWithDelay runs all Jobs with delay seconds
func (*Scheduler) RunPending ¶ added in v1.1.2
func (s *Scheduler) RunPending()
RunPending runs all the Jobs that are scheduled to run.
func (*Scheduler) StartAsync ¶ added in v1.1.2
func (s *Scheduler) StartAsync() chan struct{}
StartAsync starts a goroutine that runs all the pending using a second-long ticker
func (*Scheduler) StartBlocking ¶ added in v1.1.2
func (s *Scheduler) StartBlocking()
StartBlocking starts all the pending jobs using a second-long ticker and blocks the current thread
func (*Scheduler) StartImmediately ¶ added in v1.1.2
StartImmediately sets the Jobs next run as soon as the scheduler starts
func (*Scheduler) Stop ¶ added in v1.1.2
Stop stops the scheduler. This is a no-op if the scheduler is already stopped .