jobs

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithLogs added in v0.6.0

func WithLogs(logs *file.Streamer) func(*Job)

func WithMaskedPhrases added in v0.37.0

func WithMaskedPhrases(phrases []string) func(*Job)

WithMaskedPhrases supplies pre-known secrets to scrub from the Job's log output, typically values of CI variables marked masked=true.

func WithOperatorLogger added in v0.39.0

func WithOperatorLogger(l *slog.Logger) func(*Job)

WithOperatorLogger sets the logger for operator-facing messages (e.g. job failures). Defaults to slog.Default().

Types

type Job

type Job struct {
	TmpDir  string
	WorkDir string
	Ctx     context.Context // Cancelled when Run exits or Close is called, whichever comes first.
	ID      string          // The ID of the job to run/being run. Must be unique. Typically this will be the CI job ID.
	// contains filtered or unexported fields
}

func New

func New(jobID, workDir string, timeout time.Duration, jobCtrl *runner.JobCtrl, options ...func(*Job)) (*Job, error)

func (*Job) Cancel added in v0.35.0

func (j *Job) Cancel()

Cancel sends a cancellation request to the job, giving steps a chance to exit gracefully.

func (*Job) Close

func (j *Job) Close()

Close cancels jobs (if still running) and cleans up all resources associated with managing the job.

func (*Job) Closed added in v0.45.0

func (j *Job) Closed() <-chan struct{}

Closed is closed when Close has finished releasing the job's resources.

func (*Job) Done added in v0.45.0

func (j *Job) Done() <-chan struct{}

Done is closed when Run has returned.

func (*Job) FollowLogs

func (j *Job) FollowLogs(ctx context.Context, offset int64, writer io.Writer) error

FollowLogs writes the stdout/stderr captured from running steps to the supplied writer. The function blocks until the steps are run and logs are written to the writer. Errors returned are indicative of failure to write to the writer, not failure of running steps.

func (*Job) Interrupt added in v0.45.0

func (j *Job) Interrupt(cause error) bool

Interrupt marks a job that has not finished as failed with cause once Run returns, and reports whether it did so. Steps keep running: the caller decides when to stop serving, and stopping early would hide the cause behind a transport error. A job that has already finished is left alone (its result is final and may have been read), and so is a job that was already interrupted: the first cause is the one that matters.

func (*Job) Logs

func (j *Job) Logs() (io.Writer, io.Writer)

Logs returns the Job's stdout and stderr writers (in that order).

func (*Job) Run

func (j *Job) Run(stepsCtx *runner.StepsContext, step runner.Function)

Run actually starts execution of the steps request and captures the result. It is intended to be run in a goroutine.

func (*Job) Status

func (j *Job) Status() *proto.Status

Status returns a proto.Status representing the current state of the job.

Jump to

Keyboard shortcuts

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