schedule

package
v1.39.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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 New

func New() *Scheduler

New returns a scheduler of no jobs.

func (*Scheduler) Add

func (s *Scheduler) Add(job Job) error

Add adds job, pending. A job without an ID, or with the ID of one added already, is refused.

func (*Scheduler) CheckCycle

func (s *Scheduler) CheckCycle() error

CheckCycle refuses jobs whose needs are in a cycle. A need that is no job is not refused.

func (*Scheduler) Finish

func (s *Scheduler) Finish(id string, success bool)

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

func (s *Scheduler) Pending() []string

Pending returns the jobs that have not started, in the order they were added.

func (*Scheduler) Runnable

func (s *Scheduler) Runnable() []string

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

func (s *Scheduler) SkipBlocked() []string

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.

func (*Scheduler) Start

func (s *Scheduler) Start(id string)

Start marks the job of id as running.

func (*Scheduler) Validate

func (s *Scheduler) Validate() error

Validate refuses a need that is no job, and needs in a cycle. The jobs are looked at in the order they were added.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL