gate

package
v0.0.41 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package gate composes AnyJobs into a Gate of ordered phases, run with stop-on-failure and error aggregation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tier added in v0.0.11

func Tier() decorate.Tier

Tier is the gate tier's decoration: recovery, then logging, tracing, metrics and a timeout around one run of a gate (the "Run" operation), outermost first.

Types

type Gate

type Gate struct {
	// contains filtered or unexported fields
}

Gate is an ordered sequence of Phases with optional stop-on-failure behaviour. New starts one; Parallel, Serial, StopOnFailure and Observe extend it in place and return it, so a gate is built as one chain and run with Run or RunLocal.

func New added in v0.0.7

func New(name string) *Gate

New returns an empty gate named name that reports to no observer.

func (*Gate) Decorate added in v0.0.11

func (g *Gate) Decorate(decs decorate.Decorations) *Gate

Decorate runs g through the gate tier, decorated as decs resolves the gate-tier component named after g; it returns g.

func (*Gate) Observe added in v0.0.7

func (g *Gate) Observe(obs interfaces.ExecutionObserver) *Gate

Observe reports the gate's lifecycle events to obs; a nil obs keeps the current observer, so a caller can pass an optional observer through unchecked.

func (*Gate) Parallel added in v0.0.7

func (g *Gate) Parallel(name string, jobs ...interfaces.AnyJob) *Gate

Parallel adds a phase in which all jobs run concurrently.

func (*Gate) Phases

func (g *Gate) Phases() []Phase

Phases returns the ordered phases of the gate for inspection (e.g. in tests).

func (*Gate) Run added in v0.0.7

func (g *Gate) Run(
	ctx context.Context,
	runner interfaces.CommandRunner,
	root string,
) error

Run executes all phases of g in order against runner under root. Each phase's jobs run in parallel or serially per configuration. Failures are aggregated into a CodeQualityFailed error. When StopOnFailure is set, the first failed phase halts subsequent phases. Returns nil when all phases pass or produce only warnings.

func (*Gate) RunLocal added in v0.0.7

func (g *Gate) RunLocal(ctx context.Context) error

RunLocal runs a gate whose jobs are all runner-less (job.Base.Local). It supplies a CommandRunner that fails every command, so no phase ever receives a nil runner. Use it for in-process gates (e.g. DB seeding) that compose Local jobs rather than commands.

func (*Gate) Serial added in v0.0.7

func (g *Gate) Serial(name string, jobs ...interfaces.AnyJob) *Gate

Serial adds a phase in which jobs run one after another.

func (*Gate) StopOnFailure added in v0.0.7

func (g *Gate) StopOnFailure() *Gate

StopOnFailure makes the gate skip its remaining phases after any failure.

type GateFactory

type GateFactory interface {
	// Gate builds and returns the composed *Gate.
	Gate() *Gate
}

GateFactory is a typed producer of a *Gate. CLI workflow types that compose a gate implement it so a workflow is a modeled value (parameters as fields) rather than a bare builder function. It is a structural contract: callers use the concrete workflow type directly; future gate-producing workflows implement this interface to signal intent.

interface-composition exemption — execution-engine primitive: a single Gate() → *Gate producer contract, not an id-CRUD data-access surface, so it embeds no foundation generic.

type Phase

type Phase struct {
	// Name identifies the phase in observer events and failure messages.
	Name string

	// Jobs are the AnyJobs that make up this phase.
	Jobs []interfaces.AnyJob
	// contains filtered or unexported fields
}

Phase is a named group of AnyJobs executed either in parallel or serially.

Jump to

Keyboard shortcuts

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