Documentation ¶
Overview ¶
Package sched provides methods of scheduling tasks.
Index ¶
Constants ¶
const ( PriorityMax float64 = 1 PriorityHigh float64 = 0.9 PriorityNormal float64 = 0 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 this many proposed tasks }
Request for work.
type Scheduler ¶
Scheduler proposes work.
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 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.