Documentation
¶
Overview ¶
Package runnerpool provides a runner implementation based on a pool pattern for executing multiple units concurrently.
Index ¶
- func Build(ctx context.Context, l log.Logger, opts *options.TerragruntOptions, ...) (common.StackRunner, error)
- func BuildUnitOpts(l log.Logger, stackOpts *options.TerragruntOptions, unit *component.Unit) (*options.TerragruntOptions, log.Logger, error)
- func CloneUnitOptions(stackOpts *options.TerragruntOptions, unit *component.Unit, ...) (*options.TerragruntOptions, log.Logger, error)
- func FilterDiscoveredUnits(discovered component.Components, units []*component.Unit) component.Components
- func NewRunnerPoolStack(ctx context.Context, l log.Logger, opts *options.TerragruntOptions, ...) (common.StackRunner, error)
- func NewUnitEarlyExitError(unitPath, failedDep string) error
- func NewUnitFailedError(unitPath string) error
- type Controller
- type ControllerOption
- type Runner
- func (rnr *Runner) GetStack() *component.Stack
- func (rnr *Runner) JSONUnitDeployOrder(isDestroy bool, showAbsPaths bool) (string, error)
- func (rnr *Runner) ListStackDependentUnits() map[string][]string
- func (rnr *Runner) LogUnitDeployOrder(l log.Logger, isDestroy bool, showAbsPaths bool, ...) error
- func (rnr *Runner) Run(ctx context.Context, l log.Logger, stackOpts *options.TerragruntOptions, ...) error
- func (rnr *Runner) WithOptions(opts ...common.Option) *Runner
- type UnitEarlyExitError
- type UnitFailedError
- type UnitRunner
- type UnitWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
func Build( ctx context.Context, l log.Logger, opts *options.TerragruntOptions, runnerOpts ...common.Option, ) (common.StackRunner, error)
Build stack runner using discovery and queueing mechanisms.
func BuildUnitOpts ¶ added in v1.0.0
func BuildUnitOpts(l log.Logger, stackOpts *options.TerragruntOptions, unit *component.Unit) (*options.TerragruntOptions, log.Logger, error)
BuildUnitOpts creates per-unit opts and logger for a single unit on demand. It computes the canonical config path, clones options, applies source overrides, and transfers discovery context command/args.
func CloneUnitOptions ¶ added in v0.97.0
func CloneUnitOptions( stackOpts *options.TerragruntOptions, unit *component.Unit, canonicalConfigPath string, stackDefaultDownloadDir string, l log.Logger, ) (*options.TerragruntOptions, log.Logger, error)
CloneUnitOptions clones TerragruntOptions for a specific unit. It handles CloneWithConfigPath, per-unit DownloadDir fallback, and OriginalTerragruntConfigPath. Returns the cloned options and logger, or the original logger if stackOpts is nil.
func FilterDiscoveredUnits ¶ added in v0.89.0
func FilterDiscoveredUnits(discovered component.Components, units []*component.Unit) component.Components
FilterDiscoveredUnits removes configs for units flagged as excluded and prunes dependencies that point to excluded units. This keeps the execution queue and any user-facing listings free from units not intended to run.
Inputs:
- discovered: raw discovery results (paths and dependency edges)
- units: resolved units (slice), where exclude rules have already been applied
Behavior:
- A config is included only if there's a corresponding unit and it is not excluded.
- For each included config, its Dependencies list is filtered to only include included configs.
- The function returns a new slice with shallow-copied entries so the original discovery results remain unchanged.
func NewRunnerPoolStack ¶
func NewRunnerPoolStack( ctx context.Context, l log.Logger, opts *options.TerragruntOptions, discovered component.Components, runnerOpts ...common.Option, ) (common.StackRunner, error)
NewRunnerPoolStack creates a new stack from discovered units.
func NewUnitEarlyExitError ¶ added in v0.99.0
NewUnitEarlyExitError creates a new UnitEarlyExitError.
func NewUnitFailedError ¶ added in v0.99.0
NewUnitFailedError creates a new UnitFailedError.
Types ¶
type Controller ¶ added in v0.83.2
type Controller struct {
// contains filtered or unexported fields
}
Controller orchestrates concurrent execution over a DAG.
func NewController ¶ added in v0.83.2
func NewController(q *queue.Queue, units []*component.Unit, opts ...ControllerOption) *Controller
NewController creates a new Controller with the given options and a pre-built queue.
type ControllerOption ¶ added in v0.83.2
type ControllerOption func(*Controller)
ControllerOption is a function that modifies a Controller.
func WithMaxConcurrency ¶
func WithMaxConcurrency(concurrency int) ControllerOption
WithMaxConcurrency sets the concurrency for the Controller.
func WithRunner ¶
func WithRunner(runner UnitRunner) ControllerOption
WithRunner sets the UnitRunner for the Controller.
type Runner ¶
Runner implements the Stack interface for runner pool execution.
func (*Runner) JSONUnitDeployOrder ¶
JSONUnitDeployOrder returns the order of units to be processed for a given Terraform command in JSON format.
func (*Runner) ListStackDependentUnits ¶
ListStackDependentUnits returns a map of units and their dependent units in the stack.
func (*Runner) LogUnitDeployOrder ¶
func (rnr *Runner) LogUnitDeployOrder(l log.Logger, isDestroy bool, showAbsPaths bool, experiments experiment.Experiments) error
LogUnitDeployOrder logs the order of units to be processed. When the dag-queue-display experiment is enabled, the output is rendered as a DAG tree showing dependency relationships between units. Otherwise, a flat list is shown.
type UnitEarlyExitError ¶ added in v0.99.0
type UnitEarlyExitError struct {
UnitPath string
FailedDependency string // The dependency that caused the early exit (optional)
}
UnitEarlyExitError is an error type for units that didn't run due to dependency failure.
func (UnitEarlyExitError) Error ¶ added in v0.99.0
func (e UnitEarlyExitError) Error() string
type UnitFailedError ¶ added in v0.99.0
type UnitFailedError struct {
UnitPath string
}
UnitFailedError is an error type for units that failed during execution.
func (UnitFailedError) Error ¶ added in v0.99.0
func (e UnitFailedError) Error() string
type UnitRunner ¶ added in v0.83.2
UnitRunner defines a function type that executes a Unit within a given context and returns an error.
type UnitWriter ¶ added in v0.94.0
type UnitWriter struct {
// contains filtered or unexported fields
}
UnitWriter buffers output for a single unit and flushes incrementally during execution. This prevents interleaved output when multiple units run in parallel while ensuring output appears in real-time during execution, not just at completion.
func NewUnitWriter ¶ added in v0.94.0
func NewUnitWriter(out io.Writer) *UnitWriter
NewUnitWriter returns a new UnitWriter instance.
func (*UnitWriter) Flush ¶ added in v0.94.0
func (writer *UnitWriter) Flush() error
Flush flushes all buffered data to the output writer.
func (*UnitWriter) Unwrap ¶ added in v1.0.0
func (writer *UnitWriter) Unwrap() io.Writer
Unwrap returns the underlying output writer that this UnitWriter wraps.