Documentation
¶
Overview ¶
Package engine provides execution infrastructure: bounded concurrent fan-out, observer dispatch, job-group execution, and simple function steps.
Index ¶
- func RunJobGroup(ctx context.Context, runner interfaces.CommandRunner, root string, ...) (types.StepResults, error)
- type NopObserver
- func (NopObserver) OnGateComplete(_ string, _ types.StepResults, _ time.Duration)
- func (NopObserver) OnGateStart(_ string, _ []string)
- func (NopObserver) OnPhaseComplete(_ string, _ types.StepResults, _ time.Duration)
- func (NopObserver) OnPhaseStart(_ string, _ []string)
- func (NopObserver) OnStepComplete(_ types.StepResult)
- func (NopObserver) OnStepStart(_, _ string)
- type Pool
- type Step
- type Steps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunJobGroup ¶
func RunJobGroup( ctx context.Context, runner interfaces.CommandRunner, root string, jobs []interfaces.AnyJob, obs interfaces.ExecutionObserver, ) (types.StepResults, error)
RunJobGroup executes jobs concurrently and collects all StepResults. Each job's results are forwarded to obs.OnStepComplete as they arrive. Phase-level aggregation (obs.OnPhaseComplete) is the caller's responsibility (gate.runPhase), because a serial phase invokes RunJobGroup once per job and must fire OnPhaseComplete exactly once for the whole phase. Context cancellation stops jobs that have not yet acquired a worker slot; in-flight jobs run to completion.
Types ¶
type NopObserver ¶
type NopObserver struct{}
NopObserver is a no-op ExecutionObserver used as a safe default.
func (NopObserver) OnGateComplete ¶
func (NopObserver) OnGateComplete(_ string, _ types.StepResults, _ time.Duration)
OnGateComplete discards the gate-complete event.
func (NopObserver) OnGateStart ¶
func (NopObserver) OnGateStart(_ string, _ []string)
OnGateStart discards the gate-start event.
func (NopObserver) OnPhaseComplete ¶
func (NopObserver) OnPhaseComplete(_ string, _ types.StepResults, _ time.Duration)
OnPhaseComplete discards the phase-complete event.
func (NopObserver) OnPhaseStart ¶
func (NopObserver) OnPhaseStart(_ string, _ []string)
OnPhaseStart discards the phase-start event.
func (NopObserver) OnStepComplete ¶
func (NopObserver) OnStepComplete(_ types.StepResult)
OnStepComplete discards the step-complete event.
func (NopObserver) OnStepStart ¶
func (NopObserver) OnStepStart(_, _ string)
OnStepStart discards the step-start event.
type Pool ¶ added in v0.0.7
type Pool int
Pool bounds a fan-out's concurrency: Pool(n) runs at most n items at once, and a value <= 0 means runtime.NumCPU().
func (Pool) FanOut ¶ added in v0.0.7
func (p Pool) FanOut[T any]( ctx context.Context, items []T, fn func(ctx context.Context, item T) types.StepResult, ) types.StepResults
FanOut runs fn for each item in items with at most p items in flight.
Each invocation is isolated: a panic in fn is recovered and converted to StepResult{Status: Fail, Detail: stack} rather than crashing the process. fn returning a Fail result is passed through unchanged.
Context cancellation (via gctx derived from ctx) stops items that have not yet acquired a worker slot; items already running continue until fn returns. All results are collected -- fn always returns nil to the errgroup so no unit can cancel its siblings.
type Step ¶
type Step struct {
// Run is the work; a non-nil error fails the step.
Run func(context.Context) error
// Name identifies the step in its result.
Name string
// Group categorizes the step for display.
Group string
// WarnOnly downgrades a failure to a warning.
WarnOnly bool
}
Step is a named function run as one unit of work, for commands that need function-to-result wrapping without a job's runner and root.