job

package
v0.36.3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IgnoreState added in v0.29.0

func IgnoreState(ctx context.Context) bool

func WithIgnoreState added in v0.29.0

func WithIgnoreState(ctx context.Context, ignore bool) context.Context

Types

type DeferFunc

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

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

func (IDs) StringSlice added in v0.31.4

func (ids IDs) StringSlice() []string

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

	// Priority represents priority with which the job should be scheduled.
	// This overrides the priority implied from whether the dir is open.
	Priority JobPriority

	// 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.
	// Jobs depending on the main job won't automatically depend on
	// jobs scheduled by Defer.
	Defer DeferFunc

	// DependsOn represents any other job IDs this job depends on.
	// This will be taken into account when scheduling, so that only
	// jobs with no dependencies are dispatched at any time.
	DependsOn IDs

	// IgnoreState indicates to the job (as defined by Func)
	// whether to ignore existing state, i.e. whether to invalidate cache.
	// It is up to [Func] to read this flag from ctx and reflect it.
	IgnoreState bool
}

func (Job) Copy

func (job Job) Copy() Job

type JobPriority added in v0.29.0

type JobPriority int
const (
	LowPriority  JobPriority = -1
	HighPriority JobPriority = 1
)

type JobStore

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

type StateNotChangedErr added in v0.29.0

type StateNotChangedErr struct {
	Dir document.DirHandle
}

func (StateNotChangedErr) Error added in v0.29.0

func (e StateNotChangedErr) Error() string

Jump to

Keyboard shortcuts

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