job

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithJobStore

func WithJobStore(ctx context.Context, js JobStore) context.Context

Types

type DeferFunc

type DeferFunc func(ctx context.Context, jobErr error) IDs

DeferFunc represents a deferred function scheduling more jobs based on jobErr (any error returned from the main job). Newly queued job IDs should be returned to allow for synchronization.

type ID

type ID string

func (ID) String

func (id ID) String() string

type IDs

type IDs []ID

func (IDs) Copy

func (ids IDs) Copy() IDs

type Job

type Job struct {
	// Func represents the job to execute
	Func func(ctx context.Context) error

	// Dir describes the directory which the job belongs to,
	// which is used for deduplication of queued jobs (along with Type)
	// and prioritization
	Dir document.DirHandle

	// Type describes type of the job (e.g. GetTerraformVersion),
	// which is used for deduplication of queued jobs along with Dir.
	Type string

	// Defer is a function to execute after Func is executed
	// and before the job is marked as done (StateDone).
	// This can be used to schedule jobs dependent on the main job.
	Defer DeferFunc
}

func (Job) Copy

func (job Job) Copy() Job

type JobStore

type JobStore interface {
	EnqueueJob(newJob Job) (ID, error)
	WaitForJobs(ctx context.Context, ids ...ID) error
}

func JobStoreFromContext

func JobStoreFromContext(ctx context.Context) (JobStore, error)

Jump to

Keyboard shortcuts

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