Documentation ¶
Overview ¶
Package job provides a Scheduler to manage and execute Jobs with dependencies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
Job is a unit of work that can be executed based on the result of resolving requested dependencies.
type Scheduler ¶
type Scheduler[T comparable] struct { // contains filtered or unexported fields }
Scheduler implements a dependency graph for jobs. Jobs can be registered with dependencies, and once all dependencies are resolved, the job will be executed.
func NewScheduler ¶
func NewScheduler[T comparable]() *Scheduler[T]
func (*Scheduler[T]) Abandon ¶
Abandon a dependency. If all dependencies for a job are resolved, the job will be executed.
It is safe to call the scheduler during the execution of a job.
func (*Scheduler[T]) Fulfill ¶
Fulfill a dependency. If all dependencies for a job are resolved, the job will be executed.
It is safe to call the scheduler during the execution of a job.
func (*Scheduler[_]) NumDependencies ¶
NumDependencies returns the number of dependencies that jobs are currently blocking on.
func (*Scheduler[T]) Schedule ¶
Schedule a job to be executed once all of its dependencies are resolved. If a job is scheduled with no dependencies, it's executed immediately.
In order to prevent a memory leak, all dependencies must eventually either be fulfilled or abandoned.
While registering a job with duplicate dependencies is discouraged, it is allowed.