Documentation
¶
Overview ¶
Package gate composes AnyJobs into a Gate of ordered phases, run with stop-on-failure and error aggregation.
Index ¶
- type Gate
- func (g *Gate) Observe(obs interfaces.ExecutionObserver) *Gate
- func (g *Gate) Parallel(name string, jobs ...interfaces.AnyJob) *Gate
- func (g *Gate) Phases() []Phase
- func (g *Gate) Run(ctx context.Context, runner interfaces.CommandRunner, root string) error
- func (g *Gate) RunLocal(ctx context.Context) error
- func (g *Gate) Serial(name string, jobs ...interfaces.AnyJob) *Gate
- func (g *Gate) StopOnFailure() *Gate
- type GateFactory
- type Phase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 (*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) 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
RunLocal runs a gate whose jobs are all runner-less (job.Base.Runnable). 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 Runnables 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
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.