Documentation
¶
Overview ¶
Package chain provides a pipeline executor for configuration resolution.
This package implements a stage-based execution pipeline used by the configuration resolver to apply layered configuration from templates, engrams, stories, and step runs.
Executor ¶
The Executor runs a series of stages with configurable error handling:
executor := chain.NewExecutor(logger.WithName("resolver")).
WithObserver(chain.NewMetricsObserver("engram"))
executor.
Add(chain.Stage{Name: "template", Mode: chain.ModeFailFast, Fn: applyTemplate}).
Add(chain.Stage{Name: "engram", Mode: chain.ModeLogAndSkip, Fn: applyEngram}).
Add(chain.Stage{Name: "story", Mode: chain.ModeLogAndSkip, Fn: applyStory})
if err := executor.Run(ctx); err != nil {
return err
}
Error Modes ¶
Two error handling modes are supported:
- ModeFailFast: Stops execution when a stage returns an error
- ModeLogAndSkip: Logs the error and continues to the next stage
Observers ¶
Observers are notified of stage completion for metrics and logging:
observer := chain.NewMetricsObserver("layer_name")
executor.WithObserver(observer)
The [MetricsObserver] records Prometheus metrics for stage durations and outcomes.
Stage Outcomes ¶
Stages produce one of three outcomes:
- StageSuccess: Stage completed without error
- StageError: Stage failed with ModeFailFast
- StageSkipped: Stage failed with ModeLogAndSkip (execution continued)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor runs staged callbacks with shared logging.
func NewExecutor ¶
NewExecutor creates a resolver chain executor.
func (*Executor) Warnings ¶
func (e *Executor) Warnings() []StageError
Warnings exposes log-and-skip failures recorded during the most recent Run.
func (*Executor) WithObserver ¶
type Observer ¶
type Observer interface {
StageStarted(ctx context.Context, stage Stage)
StageCompleted(ctx context.Context, stage Stage, outcome StageOutcome, err error, duration time.Duration)
}
func NewMetricsObserver ¶
NewMetricsObserver wires resolver stage events into controller metrics.
type StageError ¶
StageError captures log-and-skip failures for later inspection.
type StageOutcome ¶
type StageOutcome string
const ( OutcomeSuccess StageOutcome = "success" OutcomeSkipped StageOutcome = "skipped" OutcomeFailed StageOutcome = "failed" )