Documentation ¶
Overview ¶
Package scheduler sends a job on a channel when it is time to run it.
The scheduler takes a Task and cron expression. At the tasks's start time, the task is sent to the run channel. This allows the control of task executon outside of the scheduler. When the task is finished, the executor calls Task.End() to tell the scheduler the task is finished.
Index ¶
Constants ¶
const RunNow = ""
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct { Context context.Context End context.CancelFunc ID cron.EntryID RunCount int Task tasks.Task }
Job is information that is output when a job runs
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler signals when items start and stop
func NewWithSeconds ¶
func NewWithSeconds() *Scheduler
Create a new scheduler that uses a non-standard cron schedule spec that contains seconds.
func (*Scheduler) Add ¶
func (s *Scheduler) Add(cronExp string, task tasks.Task, maxRunTime, scheduleLimit time.Duration, lastRunCount int) (cron.EntryID, error)
Add adds a Task to be scheduled.
func (*Scheduler) Close ¶
Close stops the scheduler and all its running jobs. The context passed to Close determines how long the scheduler waits for running jobs to complete before it cancels them. A nil context means do not wait.