job

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLocalQuarantinedReplayUnsupported = errors.New("replay requires the descriptor-aware executor")

ErrLocalQuarantinedReplayUnsupported is returned when a quarantined replay reaches the in-process executor, which is not descriptor-aware.

Functions

func CancelRunContexts

func CancelRunContexts(runID uuid.UUID) int

CancelRunContexts cancels every in-process run context registered for runID and reports how many were cancelled.

func EnumerateLogicalDates

func EnumerateLogicalDates(schedule cron.Schedule, start, end time.Time, loc *time.Location) []time.Time

EnumerateLogicalDates returns all cron fire times in [start, end). loc sets the timezone used when computing schedule boundaries; pass time.UTC when the trigger has no timezone configured.

func FilterDates

func FilterDates(store *backfillstore.Store, jobID uuid.UUID, dates []time.Time, reprocess string) ([]time.Time, error)

FilterDates filters logical dates based on the reprocess policy:

"none"   — skip dates that have any existing run
"failed" — skip dates whose latest run succeeded
"all"    — keep all dates

func RegisterRunCancel

func RegisterRunCancel(parent context.Context, runID uuid.UUID) (context.Context, func())

RegisterRunCancel derives the cancellable context a detached run must execute under. EVERY `run.WithContext(context.Background(), runID)` kickoff site wraps its parent with this call; missing one leaves that entry point's runs uncancellable, which is the bug in the first place.

ctx, release := job.RegisterRunCancel(context.Background(), r.ID)
defer release()
job.New(...).Run(runstorage.WithContext(ctx, r.ID))

func RunBackfill

func RunBackfill(
	ctx context.Context,
	b *models.Backfill,
	j *models.Job,
	schedule cron.Schedule,
	loc *time.Location,
)

RunBackfill executes a backfill by enumerating logical dates, filtering by the reprocess policy, and running each date through the standard job executor with a semaphore controlling max concurrency.

It honours ctx cancellation: when cancelled, no new runs are started but any in-flight runs are allowed to finish.

func SubscribeRunCancellations

func SubscribeRunCancellations(ctx context.Context, bus event.Bus)

SubscribeRunCancellations wires the registry to the in-process event bus: TypeRunCancelled — published by both run.Store.CancelRun and the concurrency `replace` admission, which share cancelRunTx — cancels the run's registered contexts, and the local executor's taskCtx.Done() branch then force-stops the container (internal/job/job.go).

It returns as soon as the subscription is established; the pump runs until ctx is done. A bus that refuses the subscription is logged and ignored rather than fatal: a server that cannot cancel containers is still a server that runs jobs.

Types

type Job

type Job interface {
	Run(ctx context.Context) error
}

Job

func New

func New(m *models.Job, opts ...JobOption) Job

type JobOption

type JobOption func(*job)

JobOption configures a job before execution.

func WithAtomPollInterval

func WithAtomPollInterval(interval time.Duration) JobOption

WithAtomPollInterval overrides the polling interval for atom completion checks.

func WithAtomServiceFactory

func WithAtomServiceFactory(factory func(context.Context) asvc.Atom) JobOption

WithAtomServiceFactory overrides the atom service used to look up atoms.

func WithDispatchRunCallbacks

func WithDispatchRunCallbacks(dispatch func(context.Context, uuid.UUID, uuid.UUID, error) error) JobOption

WithDispatchRunCallbacks overrides the callback dispatch function.

func WithDockerEngineFactory

func WithDockerEngineFactory(factory func(context.Context) atom.Engine) JobOption

WithDockerEngineFactory overrides the Docker engine constructor.

func WithEnvVariables

func WithEnvVariables(variables func() env.Environment) JobOption

WithEnvVariables overrides the environment configuration.

func WithKubernetesEngineFactory

func WithKubernetesEngineFactory(factory func(context.Context) atom.Engine) JobOption

WithKubernetesEngineFactory overrides the Kubernetes engine constructor.

func WithParams

func WithParams(params map[string]string) JobOption

WithParams attaches run parameters to the job. Parameters are injected into each task's environment as CAESIUM_PARAM_<KEY>=<VALUE> (KEY uppercased).

func WithPodmanEngineFactory

func WithPodmanEngineFactory(factory func(context.Context) atom.Engine) JobOption

WithPodmanEngineFactory overrides the Podman engine constructor.

func WithPriorityOverride

func WithPriorityOverride(priority string) JobOption

func WithRunStoreFactory

func WithRunStoreFactory(factory func() *run.Store) JobOption

WithRunStoreFactory overrides the run store used for execution state.

func WithSecretResolver

func WithSecretResolver(resolver secret.Resolver) JobOption

WithSecretResolver configures secret:// resolution for step environment values. If omitted, Run builds the resolver from the processed environment.

func WithTaskEdgeServiceFactory

func WithTaskEdgeServiceFactory(factory func(context.Context) taskedge.TaskEdge) JobOption

WithTaskEdgeServiceFactory overrides the task edge service used to look up edges.

func WithTaskServiceFactory

func WithTaskServiceFactory(factory func(context.Context) task.Task) JobOption

WithTaskServiceFactory overrides the task service used to look up tasks.

func WithTriggerID

func WithTriggerID(id *uuid.UUID) JobOption

Jump to

Keyboard shortcuts

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