executor

package
v0.0.78 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackoffStrategy

type BackoffStrategy string

BackoffStrategy determines delay between retries

const (
	BackoffExponential BackoffStrategy = "exponential"
	BackoffLinear      BackoffStrategy = "linear"
	BackoffFixed       BackoffStrategy = "fixed"
)

type CommandExecutor

type CommandExecutor struct {
	Shell string
}

CommandExecutor executes shell commands

func NewCommandExecutor

func NewCommandExecutor() *CommandExecutor

NewCommandExecutor creates a new command executor

func (*CommandExecutor) CanHandle

func (e *CommandExecutor) CanHandle(action *semantic.SemanticScheduledAction) bool

CanHandle determines if this executor can process the action

func (*CommandExecutor) Execute

Execute runs the command and returns the result

func (*CommandExecutor) Name

func (e *CommandExecutor) Name() string

Name returns the executor's identifier

type ExecuteOptions

type ExecuteOptions struct {
	// Context for cancellation/timeout
	Context context.Context

	// RetryPolicy defines retry behavior
	RetryPolicy *RetryPolicy

	// Dependencies are actions that must complete first
	Dependencies []string

	// Storage for persisting results
	Storage Storage

	// Hooks for lifecycle events
	Hooks *ExecutionHooks
}

ExecuteWithOptions provides advanced execution control

type ExecutionError

type ExecutionError struct {
	Message string
	Code    string
	Details map[string]interface{}
}

ExecutionError provides detailed error information

func (*ExecutionError) Error

func (e *ExecutionError) Error() string

Error implements the error interface for ExecutionError

type ExecutionHooks

type ExecutionHooks struct {
	BeforeExecute func(ctx context.Context, action *semantic.SemanticScheduledAction) error
	AfterExecute  func(ctx context.Context, action *semantic.SemanticScheduledAction, result *Result) error
	OnError       func(ctx context.Context, action *semantic.SemanticScheduledAction, err error) error
}

ExecutionHooks allows customization of execution lifecycle

type ExecutionStatus

type ExecutionStatus string

ExecutionStatus represents the state of execution

const (
	StatusPending   ExecutionStatus = "pending"
	StatusRunning   ExecutionStatus = "running"
	StatusCompleted ExecutionStatus = "completed"
	StatusFailed    ExecutionStatus = "failed"
	StatusCancelled ExecutionStatus = "cancelled"
)

type Executor

type Executor interface {
	// Execute runs an action and returns the result
	Execute(ctx context.Context, action *semantic.SemanticScheduledAction) (*Result, error)

	// CanHandle determines if this executor can process the action
	CanHandle(action *semantic.SemanticScheduledAction) bool

	// Name returns the executor's identifier
	Name() string
}

Executor is the unified interface for all execution types

type HTTPExecutor

type HTTPExecutor struct {
	Client *http.Client
}

HTTPExecutor executes HTTP-based semantic actions

func NewHTTPExecutor

func NewHTTPExecutor() *HTTPExecutor

NewHTTPExecutor creates a new HTTP executor with default settings

func (*HTTPExecutor) CanHandle

func (e *HTTPExecutor) CanHandle(action *semantic.SemanticScheduledAction) bool

CanHandle determines if this executor can process the action

func (*HTTPExecutor) Execute

Execute runs the HTTP action and returns the result

func (*HTTPExecutor) Name

func (e *HTTPExecutor) Name() string

Name returns the executor's identifier

type Registry

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

Registry manages executor implementations

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new executor registry

func (*Registry) Execute

func (r *Registry) Execute(ctx context.Context, action *semantic.SemanticScheduledAction) (*Result, error)

Execute finds the appropriate executor and runs the action

func (*Registry) Register

func (r *Registry) Register(executor Executor)

Register adds an executor to the registry

type Result

type Result struct {
	// Output is the primary execution result (stdout, response body, etc.)
	Output string

	// Status indicates the execution status
	Status ExecutionStatus

	// Metadata contains additional execution information
	Metadata map[string]interface{}

	// Error contains detailed error information if execution failed
	Error *ExecutionError

	// StartTime when execution began
	StartTime time.Time

	// EndTime when execution completed
	EndTime time.Time

	// Duration of execution
	Duration time.Duration
}

Result contains the execution output and metadata

type RetryPolicy

type RetryPolicy struct {
	MaxAttempts int
	Backoff     BackoffStrategy
}

RetryPolicy defines retry behavior

type Storage

type Storage interface {
	Save(ctx context.Context, actionID string, result *Result) error
	Load(ctx context.Context, actionID string) (*Result, error)
}

Storage interface for persisting execution state

Jump to

Keyboard shortcuts

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