Documentation ¶
Index ¶
- Variables
- type Option
- type Options
- type Scheduler
- func (s *Scheduler) AddDependency(task *Task, dependency *Task)
- func (s *Scheduler) AddTask(function TaskFunc) *Task
- func (s *Scheduler) Dependencies(task *Task) []*Task
- func (s *Scheduler) DependencyCount(task *Task) int
- func (s *Scheduler) RemoveDependency(task *Task, dependency *Task)
- func (s *Scheduler) RemoveTask(task *Task)
- func (s *Scheduler) RemoveTasks(tasks ...*Task)
- func (s *Scheduler) Run(ctx context.Context) error
- func (s *Scheduler) TaskCount() int
- func (s *Scheduler) Tasks() []*Task
- type Task
- type TaskFunc
Constants ¶
This section is empty.
Variables ¶
var ( ErrCircularDependency = errors.New("A task has a circular dependency") ErrOrderFailure = errors.New("A problem occurred sorting the tasks in the correct order") )
Scheduler related errors.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Options)
Option describes a function which mutates the scheduler's configuration.
func ConcurrentTasks ¶
ConcurrentTasks sets the maximum number of tasks to run at any given time.
type Options ¶
type Options struct {
ConcurrentTasks int
}
Options holds the scheduler's configuration.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is a concurrent task scheduler.
func New ¶
New returns a concurrent task scheduler. Tasks may be dependent on each, being sorted into a layered topological order using the Coffman-Graham algorithm.
func (*Scheduler) AddDependency ¶
AddDependency creates a dependency between the specified task itself and the dependency task. When ran, the scheduler ensures the dependency task is executed first.
func (*Scheduler) Dependencies ¶
Dependencies lists the tasks the specified task depends on.
func (*Scheduler) DependencyCount ¶
DependencyCount returns the number of tasks the specified task depends on.
func (*Scheduler) RemoveDependency ¶
RemoveDependency removes the dependency between the specified task itself and the dependency task.
func (*Scheduler) RemoveTask ¶
RemoveTask removes the specified task from the scheduler.
func (*Scheduler) RemoveTasks ¶
RemoveTasks removes the specified tasks from the scheduler.
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
Task wraps a task function.
func (*Task) Dependencies ¶
Dependencies lists the tasks the this task depends on.
func (*Task) DependencyCount ¶
DependencyCount returns the number of tasks this task depends on.
func (*Task) DependsOn ¶
DependsOn creates a dependency between this task and the dependency task. When ran, the scheduler ensures the dependency task is executed first.
func (*Task) RemoveDependency ¶
RemoveDependency removes the dependency between this task and the dependency task.