Documentation ¶
Overview ¶
Package scheduler is a small library that you can use within your application that enables you to execute callbacks (goroutines) after a pre-defined amount of time. GTS also provides task storage which is used to invoke callbacks for tasks which couldn’t be executed during down-time as well as maintaining a history of the callbacks that got executed.
Index ¶
- type Scheduler
- func (scheduler *Scheduler) Cancel(taskID task.ID) error
- func (scheduler *Scheduler) Clear()
- func (scheduler *Scheduler) RunAfter(duration time.Duration, function task.Function, params ...task.Param) (task.ID, error)
- func (scheduler *Scheduler) RunAt(time time.Time, function task.Function, params ...task.Param) (task.ID, error)
- func (scheduler *Scheduler) RunEvery(duration time.Duration, function task.Function, params ...task.Param) (task.ID, error)
- func (scheduler *Scheduler) Start() error
- func (scheduler *Scheduler) Stop()
- func (scheduler *Scheduler) Wait()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is used to schedule tasks. It holds information about those tasks including metadata such as argument types and schedule times
func (*Scheduler) Cancel ¶
Cancel is used to cancel the planned execution of a specific task using it's ID. The ID is returned when the task was scheduled using RunAt, RunAfter or RunEvery
func (*Scheduler) Clear ¶
func (scheduler *Scheduler) Clear()
Clear will cancel the execution and clear all registered tasks.
func (*Scheduler) RunAfter ¶
func (scheduler *Scheduler) RunAfter(duration time.Duration, function task.Function, params ...task.Param) (task.ID, error)
RunAfter executes function once after a specific duration has elapsed.
func (*Scheduler) RunAt ¶
func (scheduler *Scheduler) RunAt(time time.Time, function task.Function, params ...task.Param) (task.ID, error)
RunAt will schedule function to be executed once at the given time.
func (*Scheduler) RunEvery ¶
func (scheduler *Scheduler) RunEvery(duration time.Duration, function task.Function, params ...task.Param) (task.ID, error)
RunEvery will schedule function to be executed every time the duration has elapsed.