Documentation
¶
Overview ¶
Package gate provides Phase, Gate, GateBuilder, and RunGate for composing AnyJobs into ordered phases with stop-on-failure and error aggregation.
Index ¶
- func RunGate(ctx context.Context, runner interfaces.CommandRunner, root string, g *Gate) error
- func RunGateNoRunner(ctx context.Context, g *Gate) error
- type Gate
- type GateBuilder
- func (b *GateBuilder) Build() *Gate
- func (b *GateBuilder) Parallel(name string, jobs ...interfaces.AnyJob) *GateBuilder
- func (b *GateBuilder) Serial(name string, jobs ...interfaces.AnyJob) *GateBuilder
- func (b *GateBuilder) StopOnFailure() *GateBuilder
- func (b *GateBuilder) WithObserver(obs interfaces.ExecutionObserver) *GateBuilder
- type GateFactory
- type Phase
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. When StopOnFailure is set, the first failed phase halts subsequent phases. Returns nil when all phases pass or produce only warnings.
func RunGateNoRunner ¶
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.
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) 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.
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.