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

gate

package
v0.1.3 Latest Latest
Warning

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

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

Documentation

Overview

Package gate provides Phase, Gate, GateBuilder, and RunGate for composing AnyJobs into ordered phases with stop-on-failure and error aggregation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunGate

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

RunGate executes all phases of g in order. Each phase's jobs run in parallel or serially per configuration. Failures are aggregated into a CodeQualityFailed error (Pattern #21). When StopOnFailure is set, the first failed phase halts subsequent phases. Returns nil when all phases pass or produce only warnings.

func RunGateNoRunner

func RunGateNoRunner(ctx context.Context, g *Gate) error

RunGateNoRunner runs a gate whose jobs are all runner-less (Runnable-backed via job.Adapt). It supplies a no-op CommandRunner so no phase ever receives a nil runner; the runner is structurally unused by Runnable-backed jobs. Use it for in-process gates (e.g. DB seeding) that compose Runnables rather than commands.

Types

type Gate

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

Gate is an ordered sequence of Phases with optional stop-on-failure behaviour. Field order: obs (interface) then name (string) before phases (slice) to keep pointer-scan range at 40 bytes instead of 48.

func (*Gate) Phases

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

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

type GateBuilder

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

GateBuilder assembles a Gate via a fluent API.

func NewGate

func NewGate(name string) *GateBuilder

NewGate returns a GateBuilder for a named gate.

func (*GateBuilder) Build

func (b *GateBuilder) Build() *Gate

Build returns the configured Gate.

func (*GateBuilder) Parallel

func (b *GateBuilder) Parallel(name string, jobs ...interfaces.AnyJob) *GateBuilder

Parallel adds a phase in which all jobs run concurrently.

func (*GateBuilder) Serial

func (b *GateBuilder) Serial(name string, jobs ...interfaces.AnyJob) *GateBuilder

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

func (*GateBuilder) StopOnFailure

func (b *GateBuilder) StopOnFailure() *GateBuilder

StopOnFailure configures the gate to skip remaining phases after any failure.

func (*GateBuilder) WithObserver

func (b *GateBuilder) WithObserver(obs interfaces.ExecutionObserver) *GateBuilder

WithObserver sets an ExecutionObserver for all phases.

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.

§2.3 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