executor

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DependencyGraph

type DependencyGraph struct {
	// contains filtered or unexported fields
}

DependencyGraph represents a directed acyclic graph for dependency resolution

func NewDependencyGraph

func NewDependencyGraph() *DependencyGraph

NewDependencyGraph creates a new dependency graph

func (*DependencyGraph) AddEdge

func (g *DependencyGraph) AddEdge(from, to string)

AddEdge adds a directed edge from 'from' to 'to'

func (*DependencyGraph) AddNode

func (g *DependencyGraph) AddNode(id string, resource *types.ResourceDiff)

AddNode adds a node to the graph

func (*DependencyGraph) TopologicalSort

func (g *DependencyGraph) TopologicalSort() ([][]*types.ResourceDiff, error)

TopologicalSort performs a topological sort and returns batches of resources that can be executed in parallel

type EnhancedParallelExecutor

type EnhancedParallelExecutor struct {
	*ParallelExecutor
	// contains filtered or unexported fields
}

EnhancedParallelExecutor extends ParallelExecutor with rollback capabilities

func NewEnhancedParallelExecutor

func NewEnhancedParallelExecutor(maxConcurrency int, timeout time.Duration, enableRollback bool) *EnhancedParallelExecutor

NewEnhancedParallelExecutor creates a new enhanced executor with rollback

func (*EnhancedParallelExecutor) ExecuteWithRollback

func (e *EnhancedParallelExecutor) ExecuteWithRollback(ctx context.Context, plan *ExecutionPlan, executor func(context.Context, *types.ResourceDiff) error, reader func(context.Context, *types.ResourceDiff) (map[string]interface{}, error)) ([]ExecutionResult, error)

ExecuteWithRollback executes a plan with automatic rollback on failure

type ErrorRecovery

type ErrorRecovery struct {
	// contains filtered or unexported fields
}

ErrorRecovery handles different types of errors and suggests recovery actions

func NewErrorRecovery

func NewErrorRecovery() *ErrorRecovery

NewErrorRecovery creates a new error recovery system

func (*ErrorRecovery) RecoverFromError

func (e *ErrorRecovery) RecoverFromError(ctx context.Context, err error, diff *types.ResourceDiff) error

RecoverFromError attempts to recover from an error using registered strategies

type ExecutionBatch

type ExecutionBatch struct {
	Resources []*types.ResourceDiff `json:"resources"`
	BatchID   int                   `json:"batch_id"`
}

ExecutionBatch represents a batch of resources that can be executed in parallel

type ExecutionPlan

type ExecutionPlan struct {
	Batches []ExecutionBatch `json:"batches"`
}

ExecutionPlan represents a plan for parallel execution

type ExecutionResult

type ExecutionResult struct {
	ResourceID string        `json:"resource_id"`
	Success    bool          `json:"success"`
	Error      error         `json:"error,omitempty"`
	Duration   time.Duration `json:"duration"`
	Changes    []string      `json:"changes,omitempty"`
}

ExecutionResult represents the result of executing a resource

type ParallelExecutor

type ParallelExecutor struct {
	// contains filtered or unexported fields
}

ParallelExecutor executes resources in parallel while respecting dependencies

func NewParallelExecutor

func NewParallelExecutor(maxConcurrency int, timeout time.Duration) *ParallelExecutor

NewParallelExecutor creates a new parallel executor

func (*ParallelExecutor) CreateExecutionPlan

func (e *ParallelExecutor) CreateExecutionPlan(diffs []*types.ResourceDiff) (*ExecutionPlan, error)

CreateExecutionPlan creates an execution plan that respects dependencies

func (*ParallelExecutor) Execute

Execute executes the plan in parallel

type RecoveryStrategy

type RecoveryStrategy struct {
	Name        string
	Description string
	Action      func(context.Context, error, *types.ResourceDiff) error
}

RecoveryStrategy defines how to recover from specific error types

type RollbackAction

type RollbackAction struct {
	ResourceID  string                 `json:"resource_id"`
	Action      types.DiffAction       `json:"action"`
	PrevState   map[string]interface{} `json:"prev_state"`
	Timestamp   time.Time              `json:"timestamp"`
	Description string                 `json:"description"`
}

RollbackAction represents an action that can be rolled back

type RollbackExecutor

type RollbackExecutor struct {
	// contains filtered or unexported fields
}

RollbackExecutor handles rollback operations

func NewRollbackExecutor

func NewRollbackExecutor(maxRetries int, retryDelay time.Duration) *RollbackExecutor

NewRollbackExecutor creates a new rollback executor

func (*RollbackExecutor) CreateRollbackPlan

func (r *RollbackExecutor) CreateRollbackPlan(results []ExecutionResult, prevStates map[string]map[string]interface{}) *RollbackPlan

CreateRollbackPlan creates a rollback plan from execution results

func (*RollbackExecutor) ExecuteRollback

func (r *RollbackExecutor) ExecuteRollback(ctx context.Context, plan *RollbackPlan, executor func(context.Context, *types.ResourceDiff) error) error

ExecuteRollback executes a rollback plan

type RollbackPlan

type RollbackPlan struct {
	Actions   []RollbackAction `json:"actions"`
	CreatedAt time.Time        `json:"created_at"`
}

RollbackPlan represents a plan for rolling back changes

Jump to

Keyboard shortcuts

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