Documentation
¶
Overview ¶
Package schedule tells which jobs of a run can start, from the jobs each one needs and how those ended. It knows a job by its ID, its needs and whether it always runs, and nothing of what running one is.
Index ¶
- type Job
- type Scheduler
- func (s *Scheduler) Add(job Job) error
- func (s *Scheduler) CheckCycle() error
- func (s *Scheduler) Finish(id string, success bool)
- func (s *Scheduler) Pending() []string
- func (s *Scheduler) Runnable() []string
- func (s *Scheduler) SkipBlocked() []string
- func (s *Scheduler) Start(id string)
- func (s *Scheduler) Validate() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct {
ID string
// Needs are the IDs of the jobs this one waits for.
Needs []string
// Always is whether the job runs once the jobs it needs are over,
// however they ended, rather than only when they all succeeded.
Always bool
}
Job is what the scheduler knows of a job.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler tells which jobs can start. It is safe for use by goroutines at once.
func (*Scheduler) Add ¶
Add adds job, pending. A job without an ID, or with the ID of one added already, is refused.
func (*Scheduler) CheckCycle ¶
CheckCycle refuses jobs whose needs are in a cycle. A need that is no job is not refused.
func (*Scheduler) Finish ¶
Finish marks the job of id as over, and whether it succeeded. The jobs that need it can start from then on, so it is called once, when nothing more of the job is to be done.
func (*Scheduler) Pending ¶
Pending returns the jobs that have not started, in the order they were added.
func (*Scheduler) Runnable ¶
Runnable returns the pending jobs that can start, in the order they were added: those whose needs all succeeded, and those that always run whose needs are all over.
func (*Scheduler) SkipBlocked ¶
SkipBlocked skips the pending jobs that a job they need did not succeed in, except those that always run, and returns them in the order they were added. A skipped job skips the jobs that need it in turn, however deep the chain of needs is.