Documentation
¶
Overview ¶
Package execution orchestrates cleaner execution via Azure/go-workflow. It replaces the former sequential for-loop in the command layer with a proper DAG-based workflow engine that supports parallel execution, step hooks, and structured error collection.
The execution layer is deliberately DI-agnostic: it receives a *cleaner.Registry and selected cleaner names as plain parameters, matching BuildFlow's execution package design where the workflow engine never imports the DI container.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder compiles a cleaner registry into a go-workflow DAG. It is DI-agnostic — it receives a *cleaner.Registry and selected names as plain parameters, matching BuildFlow's execution package design.
func NewBuilder ¶
NewBuilder creates a Builder with the given options.
func (*Builder) BuildClean ¶
func (b *Builder) BuildClean(registry *cleaner.Registry, selected []string) (*CompiledWorkflow, error)
BuildClean compiles a clean workflow from the given registry and selected cleaner names. Each selected cleaner becomes a parallel flow.FuncIO step with BeforeStep/AfterStep hooks.
func (*Builder) BuildScan ¶
func (b *Builder) BuildScan(registry *cleaner.Registry, selected []string) (*CompiledWorkflow, error)
BuildScan compiles a scan workflow from the given registry and selected cleaner names. Each selected cleaner becomes a parallel flow.FuncIO step.
func (*Builder) WithRetryConfig ¶
func (b *Builder) WithRetryConfig(cfg *RetryConfig) *Builder
WithRetryConfig enables per-step retry on the builder.
type CompiledWorkflow ¶
CompiledWorkflow holds a ready-to-execute workflow and its result collector.
type RetryConfig ¶
RetryConfig controls per-step retry behavior for the workflow. When MaxAttempts is 0, retries are disabled.
func DefaultRetryConfig ¶
func DefaultRetryConfig() RetryConfig
DefaultRetryConfig returns sensible defaults for cleaner retries: 3 attempts, starting at 2s, capped at 30s.
func RetryConfigFromAttempts ¶
func RetryConfigFromAttempts(maxAttempts int) *RetryConfig
RetryConfigFromAttempts returns a RetryConfig with the given max attempts and default backoff settings. This is the shared builder used by both clean and scan commands to avoid duplicating inline RetryConfig literals.
type RunOption ¶
type RunOption func(*runConfig)
RunOption configures a RunCleaners invocation.
func WithMaxConcurrency ¶
WithMaxConcurrency sets the maximum number of cleaners that may run concurrently. A value of 0 (the default) means unlimited.
func WithRetry ¶
func WithRetry(cfg *RetryConfig) RunOption
WithRetry enables per-step retry with the given configuration. Passing nil disables retries (the default).
func WithVerbose ¶
WithVerbose enables or disables per-step debug output during workflow execution.
type StepResult ¶
StepResult holds the outcome of a single cleaner step within the workflow.
func (StepResult) Status ¶
func (s StepResult) Status() StepStatus
Status returns the classification for this step result. Infrastructure errors (binary not installed, system can't serve) are classified as Skipped. All other error families — Transient (after retries exhausted), Rejection, Conflict, Corruption — are Failures.
type StepStatus ¶
type StepStatus string
Status classifies a step result as succeeded, skipped, or failed.
const ( StepStatusSucceeded StepStatus = "succeeded" StepStatusSkipped StepStatus = "skipped" StepStatusFailed StepStatus = "failed" )
type WorkflowResult ¶
type WorkflowResult struct {
Steps []StepResult
TotalBytesFreed uint64
TotalItemsRemoved uint
TotalItemsFailed uint
Duration time.Duration
}
WorkflowResult aggregates results from all cleaner steps in a workflow run.
func RunCleaners ¶
func RunCleaners( ctx context.Context, registry *cleaner.Registry, selected []string, opts ...RunOption, ) (*WorkflowResult, error)
RunCleaners builds and executes a clean workflow for the given selected cleaners. It resolves cleaners from the registry, compiles them into a go-workflow DAG, executes it with the configured options, and returns aggregated results.
The workflow runs steps in parallel up to maxConcurrency. Step errors are collected per-step (not short-circuited) so that one cleaner failure does not prevent others from running.
func RunScans ¶
func RunScans( ctx context.Context, registry *cleaner.Registry, selected []string, opts ...RunOption, ) (*WorkflowResult, error)
RunScans builds and executes a scan workflow for the given selected cleaners. Each cleaner's Scan method runs as a parallel workflow step.
func (*WorkflowResult) CleanResultsMap ¶
func (wr *WorkflowResult) CleanResultsMap() map[string]domain.CleanResult
CleanResultsMap builds a name→CleanResult map for successful steps, matching the shape expected by the existing display functions.
func (*WorkflowResult) Failed ¶
func (wr *WorkflowResult) Failed() []StepResult
Failed returns only steps that failed with a non-availability error.
func (*WorkflowResult) Skipped ¶
func (wr *WorkflowResult) Skipped() []StepResult
Skipped returns only steps that were skipped (cleaner not available).
func (*WorkflowResult) Succeeded ¶
func (wr *WorkflowResult) Succeeded() []StepResult
Succeeded returns only steps that completed successfully.