Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInterrupted = errors.New("apply: interrupted")
ErrInterrupted marks an execution that was stopped at a step boundary on purpose. The steps that already succeeded stay applied, so the caller owns the recovery decision instead of the package guessing it.
Functions ¶
This section is empty.
Types ¶
type ExecutionResult ¶
type ExecutionResult struct {
Prepare StageResult
Apply StageResult
Rollback StageResult
Err error
}
type FailurePolicy ¶
type FailurePolicy int
FailurePolicy controls how the runner behaves when a step fails.
const ( // StopOnError stops execution at the first failed step (default). StopOnError FailurePolicy = iota // ContinueOnError continues executing remaining steps, collecting all errors. ContinueOnError )
type InterruptHook ¶ added in v1.4.0
InterruptHook is invoked after each successful step with the number of steps completed in that stage. Returning an error stops the execution at that boundary. It is the deterministic seam that makes an interrupted commit testable without killing a process.
type Orchestrator ¶
type Orchestrator struct {
// contains filtered or unexported fields
}
func NewOrchestrator ¶
func NewOrchestrator(policy RollbackPolicy, opts ...OrchestratorOption) *Orchestrator
func (*Orchestrator) Execute ¶
func (o *Orchestrator) Execute(plan StagePlan) ExecutionResult
type OrchestratorOption ¶
type OrchestratorOption func(*Orchestrator)
OrchestratorOption configures the orchestrator.
func WithFailurePolicy ¶
func WithFailurePolicy(policy FailurePolicy) OrchestratorOption
WithFailurePolicy sets the failure policy for the apply stage runner.
func WithInterruptHook ¶ added in v1.4.0
func WithInterruptHook(fn InterruptHook) OrchestratorOption
WithInterruptHook sets the hook invoked after each successful step. It is the deterministic seam that lets a caller exercise an interrupted commit without killing a process.
func WithProgressFunc ¶
func WithProgressFunc(fn ProgressFunc) OrchestratorOption
WithProgressFunc sets a callback that receives progress events during execution.
type ProgressEvent ¶
type ProgressEvent struct {
StepID string
Stage Stage
Status StepStatus
Err error
}
ProgressEvent is emitted by the runner as each step starts and completes.
type ProgressFunc ¶
type ProgressFunc func(ProgressEvent)
ProgressFunc is a callback invoked for every step lifecycle event.
type RollbackPolicy ¶
func DefaultRollbackPolicy ¶
func DefaultRollbackPolicy() RollbackPolicy
func (RollbackPolicy) ShouldRollback ¶
func (p RollbackPolicy) ShouldRollback(stage Stage, err error) bool
type RollbackStep ¶
type Runner ¶
type Runner struct {
FailurePolicy FailurePolicy
OnProgress ProgressFunc
Interrupt InterruptHook
}
Runner executes a list of steps for a given stage.
type StageResult ¶
type StageResult struct {
Stage Stage
Steps []StepResult
Success bool
Err error
}
func ExecuteRollback ¶
func ExecuteRollback(steps []StepResult, stepIndex map[string]Step) StageResult
type StepResult ¶
type StepStatus ¶
type StepStatus string
const ( StepStatusPending StepStatus = "pending" StepStatusRunning StepStatus = "running" StepStatusSucceeded StepStatus = "succeeded" StepStatusFailed StepStatus = "failed" StepStatusRolledBack StepStatus = "rolled-back" StepStatusSkipped StepStatus = "skipped" )