batch

package
v1.13.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeduplicateTargets deprecated

func DeduplicateTargets(targets []ResolvedTarget) ([]ResolvedTarget, []ItemResult)

DeduplicateTargets keeps first occurrence and reports duplicates as skipped.

Deprecated: transitional v1.1 helper from the legacy plan-based path. Prefer PrepareTargets for new code.

func ExitCodeFromReport

func ExitCodeFromReport(report Report) int

ExitCodeFromReport returns zero when all items succeeded or were skipped.

func FormatHuman

func FormatHuman(report Report) string

FormatHuman renders a stable, human-readable report.

func HasExecutableTargets

func HasExecutableTargets(targets []PreparedTarget) bool

HasExecutableTargets reports whether at least one target can be executed.

func ResolveTargets deprecated

func ResolveTargets(raw []RawTarget) ([]ResolvedTarget, []ItemResult)

ResolveTargets validates and parses raw targets into integer IDs.

Deprecated: transitional v1.1 helper from the legacy plan-based path. Prefer PrepareTargets for new code.

Types

type ExecuteOptions deprecated

type ExecuteOptions struct {
	DryRun   bool
	FailFast bool
}

ExecuteOptions controls execution semantics.

Deprecated: transitional v1.1 type for ExecutePlan.

type ExecutionMode added in v1.2.0

type ExecutionMode string

ExecutionMode identifies batch execution strategy semantics.

const (
	ExecutionModeContinueOnError ExecutionMode = "continue_on_error"
	ExecutionModeFailFast        ExecutionMode = "fail_fast"
)

type ItemResult

type ItemResult struct {
	ID                int64            `json:"id"`
	RawValue          string           `json:"raw_value,omitempty"`
	Status            ItemResultStatus `json:"status"`
	Message           string           `json:"message,omitempty"`
	InvariantCode     string           `json:"invariant_code,omitempty"`
	RecommendedAction string           `json:"recommended_action,omitempty"`
	OutputPath        string           `json:"output_path,omitempty"`
	OriginalName      string           `json:"original_name,omitempty"`
}

ItemResult describes the outcome of one target.

type ItemResultStatus

type ItemResultStatus string

ItemResultStatus is the per-item execution outcome.

const (
	ResultSuccess ItemResultStatus = "success"
	ResultFailed  ItemResultStatus = "failed"
	ResultSkipped ItemResultStatus = "skipped"
	ResultPlanned ItemResultStatus = "planned"
)

type OperationType

type OperationType string

OperationType identifies the command-level operation executed in a batch.

const (
	OperationRestore OperationType = "restore"
	OperationRemove  OperationType = "remove"
	OperationRepair  OperationType = "repair"
)

type Plan deprecated

type Plan struct {
	Items []PlanItem
}

Plan is a sequence of planned operations.

Deprecated: transitional v1.1 type used only by legacy plan-based helpers.

func BuildPlan deprecated

func BuildPlan(op OperationType, targets []ResolvedTarget) Plan

BuildPlan creates a deterministic execution plan from resolved targets.

Deprecated: transitional v1.1 helper from the legacy plan-based path. Prefer PrepareTargets + ExecutePrepared for new code.

type PlanItem deprecated

type PlanItem struct {
	Op      OperationType
	Target  ResolvedTarget
	Skipped bool
	Reason  string
}

PlanItem is a single planned batch operation.

Deprecated: transitional v1.1 type used only by legacy plan-based helpers.

type PreparedTarget

type PreparedTarget struct {
	ID         int64
	Executable bool
	Result     ItemResult
}

PreparedTarget retains input-order target preparation state.

func PrepareTargets

func PrepareTargets(raw []RawTarget) []PreparedTarget

PrepareTargets parses and deduplicates raw targets while preserving input order.

type RawTarget

type RawTarget struct {
	Value  string
	Source string
}

RawTarget is a target as entered by the user, before normalization.

func LoadRawTargets

func LoadRawTargets(args []string, inputFile string) ([]RawTarget, error)

LoadRawTargets collects targets from positional args and optional input file.

type Report

type Report struct {
	Operation     OperationType `json:"operation"`
	DryRun        bool          `json:"dry_run"`
	ExecutionMode ExecutionMode `json:"execution_mode"`
	Summary       Summary       `json:"summary"`
	Results       []ItemResult  `json:"results"`
}

Report contains per-item outcomes and an aggregate summary.

func ExecutePlan deprecated

func ExecutePlan(plan Plan, opts ExecuteOptions, execFunc func(id int64) (string, error)) Report

ExecutePlan runs a plan using a per-item execution callback.

Deprecated: transitional v1.1 helper from the legacy plan-based path. Prefer ExecutePrepared for new code.

func ExecutePrepared

func ExecutePrepared(op OperationType, dryRun bool, failFast bool, targets []PreparedTarget, execFunc func(id int64) ItemResult) Report

ExecutePrepared runs prepared targets in input order.

func NewReport

func NewReport(op OperationType, dryRun bool, results []ItemResult) Report

NewReport builds a report and computes its summary.

type ResolvedTarget deprecated

type ResolvedTarget struct {
	ID int64
}

ResolvedTarget is a validated target ready for planning.

Deprecated: transitional v1.1 type kept for legacy plan-based helpers (ResolveTargets/DeduplicateTargets/BuildPlan/ExecutePlan). New CLI paths use RawTarget -> PrepareTargets -> ExecutePrepared.

type Summary

type Summary struct {
	Total   int `json:"total"`
	Planned int `json:"planned"`
	Success int `json:"success"`
	Failed  int `json:"failed"`
	Skipped int `json:"skipped"`
}

Summary aggregates all item outcomes.

func Summarize

func Summarize(results []ItemResult) Summary

Summarize computes aggregate counts from per-item results.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL