Documentation ¶
Index ¶
Constants ¶
const Stop time.Duration = -1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ScheduleOption ¶
type ScheduleOption func(*Task)
ScheduleOption is a function configuring a task.
func NextAfterDuration ¶
func NextAfterDuration(d time.Duration) ScheduleOption
NextAfterDuration configures the task to only run after the given amount of wall time.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func New ¶
func New() *Scheduler
New creates a new scheduler instance. The slot count defaults to the number CPUs in the system.
func (*Scheduler) Add ¶
func (s *Scheduler) Add(fn TaskFunc, opts ...ScheduleOption)
Add a new task function to the scheduler. Unless configured otherwise through an option tasks are started in the order they're added.
func (*Scheduler) Quiesce ¶
Quiesce waits until all tasks have been run or the context is cancelled. Tasks are not affected on context cancellation. If tasks are added concurrently the behaviour is unspecified.
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task describes one scheduled tasks.
type TaskError ¶
type TaskError struct { // Underlying error Err error // Delay before re-running the task. Use a negative value to make the error // permanent (i.e. don't schedule a retry). RetryDelay time.Duration }
func AsTaskError ¶
type TaskFunc ¶
TaskFunc is the signature of functions implementing tasks. They're called when it's the task's turn. Returning nil indicates success and the task is removed from the queue. *TaskError can be returned to configure a retry delay. A non-nil error of another type is always a permanent failure.