Help us shape the future of Go! Take the 2026 Go Developer Survey

staging

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package staging wires the artifact plane into job execution.

It lives apart from the artifact package to break an import cycle: the middleware signature takes a *job.Job, and job imports artifact for its input declarations.

The middleware stages a job's declared inputs before the handler runs, puts an artifact.Accessor in the context, and releases every cache lease afterwards — whether the handler returns, fails, or panics.

Running staging as middleware rather than inside the executor is also the right seam for out-of-process execution: staging happens outside the boundary, so a sandboxed handler receives a directory of files rather than storage credentials.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LinkInputs

func LinkInputs(ctx context.Context, svc *artifact.Service, j *job.Job, bindings Bindings) error

LinkInputs records which artifacts a job consumed, so lineage survives after the job finishes.

func Middleware

func Middleware(
	svc *artifact.Service,
	c *cache.Cache,
	lookup SpecLookup,
	opts ...Option,
) middleware.Middleware

Middleware stages a job's declared inputs, exposes them through an artifact.Accessor on the context, and releases every cache lease when the handler returns.

It slots into the existing middleware chain, so nothing in the executor changes. That also makes it the natural boundary for out-of-process execution later: staging runs outside, and the handler sees files rather than credentials.

func SetBindings

func SetBindings(j *job.Job, b Bindings) error

SetBindings encodes bindings onto a job.

They travel in their own field rather than inside Payload because the payload is opaque to the engine: refs buried there would be invisible to the scheduler, which needs the total input size before it picks a worker, and to this middleware, which needs them before the handler runs.

func TotalBoundSize

func TotalBoundSize(b Bindings) int64

TotalBoundSize sums the sizes of the bound artifacts, which is the figure the scheduler and the staging budget both care about.

func Validate

func Validate(specs []artifact.InputSpec, b Bindings) error

Validate checks bindings against a definition's declarations.

Both directions are errors: a binding with no declaration is a programming mistake, and a missing required declaration means the job cannot run. Catching them at enqueue keeps them out of the retry path.

Types

type Bindings

type Bindings map[string]artifact.Ref

Bindings maps declared input names to the artifacts bound to them.

func GetBindings

func GetBindings(j *job.Job) (Bindings, error)

GetBindings decodes a job's bindings. A job with none yields an empty map rather than an error.

type Option

type Option func(*Options)

Option configures the middleware.

func WithLogger

func WithLogger(l log.Logger) Option

WithLogger sets the logger.

type Options

type Options struct {
	Logger log.Logger
}

Options configures the middleware.

type SpecLookup

type SpecLookup func(jobName string) []artifact.InputSpec

SpecLookup resolves a job name to its declared inputs. The engine supplies one backed by the job registry.

Jump to

Keyboard shortcuts

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