Documentation ¶
Overview ¶
Package sched provides methods of scheduling tasks.
Index ¶
- Constants
- type Request
- type Scheduler
- func CompositeScheduler(schedulers ...Scheduler) Scheduler
- func NewDefault(d *db.DB) Scheduler
- func NewRecentCommits(d *db.DB, pri TimePriority) Scheduler
- func NewRetry(d *db.DB, maxErrors int, cooloff time.Duration) Scheduler
- func SingleTaskScheduler(task *Task) Scheduler
- func StaticScheduler(tasks []*Task) Scheduler
- type SchedulerFunc
- type Task
- type TasksByPriority
- type TimePriority
Constants ¶
const ( PriorityMax float64 = 1 PriorityHighest float64 = 0.9 PriorityHigh float64 = 0.5 PriorityNormal float64 = 0 PriorityLow float64 = -0.5 PriorityIdle float64 = -0.9 PriorityMin float64 = -1 )
Suggested priority values.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request struct { Worker string // worker to request for Num int // request at least this many proposed tasks }
Request for work.
type Scheduler ¶
Scheduler proposes work.
func CompositeScheduler ¶
CompositeScheduler merges proposed tasks from multiple schedulers.
func NewDefault ¶
NewDefault builds a scheduler with sensible defaults.
func NewRecentCommits ¶
func NewRecentCommits(d *db.DB, pri TimePriority) Scheduler
NewRecentCommits builds a scheduler that proposes tasks for recent comments and modules with no completed tasks in the database. Priority is computed with the commit time and supplied priority function.
func NewRetry ¶
NewRetry builds a scheduler that retries previous error tasks, for which there has never been a successful completion. The scheduler will stop suggestiing retries after maxErrors total errors for a commit module pair. Retries will only be scheduled after the given cooloff period.
func SingleTaskScheduler ¶
SingleTaskScheduler always returns the given task.
func StaticScheduler ¶
StaticScheduler always returns the same tasks.
type SchedulerFunc ¶
SchedulerFunc adapts a function to the Scheduler interface.
type TasksByPriority ¶
type TasksByPriority []*Task
TasksByPriority provides a sort.Interface for sorting tasks in increasing priority.
func (TasksByPriority) Len ¶
func (t TasksByPriority) Len() int
func (TasksByPriority) Less ¶
func (t TasksByPriority) Less(i, j int) bool
func (TasksByPriority) Swap ¶
func (t TasksByPriority) Swap(i, j int)
type TimePriority ¶
TimePriority is a method of determining priority based on a time.
func ConstantTimePriority ¶
func ConstantTimePriority(p float64) TimePriority
ConstantTimePriority returns a function that returns p for all times.
func TimeSinceSmoothStep ¶
TimeSinceSmoothStep has priority p0 for times up to d0 from now, priority p1 for times over d1 from now and smoothly transitions between the two.