executor

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunSpageTemporalWorkerAndWorkflow

func RunSpageTemporalWorkerAndWorkflow(opts RunSpageTemporalWorkerAndWorkflowOptions)

RunSpageTemporalWorkerAndWorkflow sets up and runs a Temporal worker for Spage tasks, and can optionally trigger a workflow execution.

func SpageTemporalWorkflow

func SpageTemporalWorkflow(ctx workflow.Context, graphInput *pkg.Graph, inventoryInput *pkg.Inventory, spageConfigInput *config.Config) error

SpageTemporalWorkflow defines the main workflow logic.

Types

type LocalTaskRunner

type LocalTaskRunner struct{}

LocalTaskRunner implements the TaskRunner interface for local execution. It directly calls the task's ExecuteModule method.

func (*LocalTaskRunner) ExecuteTask

func (r *LocalTaskRunner) ExecuteTask(ctx context.Context, task pkg.Task, closure *pkg.Closure, cfg *config.Config) pkg.TaskResult

RunTask executes a task locally. It directly calls task.ExecuteModule and returns its result. The TaskResult from ExecuteModule is expected to be populated by handleResult (called within ExecuteModule).

func (*LocalTaskRunner) RevertTask

func (r *LocalTaskRunner) RevertTask(ctx context.Context, task pkg.Task, closure *pkg.Closure, cfg *config.Config) pkg.TaskResult

type RunSpageTemporalWorkerAndWorkflowOptions

type RunSpageTemporalWorkerAndWorkflowOptions struct {
	Graph            *pkg.Graph
	InventoryPath    string
	LoadedConfig     *config.Config // Changed from ConfigPath to break import cycle with cmd
	WorkflowIDPrefix string
}

RunSpageTemporalWorkerAndWorkflowOptions defines options for RunSpageTemporalWorkerAndWorkflow.

type SpageActivityInput

type SpageActivityInput struct {
	TaskDefinition   pkg.Task
	TargetHost       pkg.Host
	LoopItem         interface{} // nil if not a loop task or for the main item
	CurrentHostFacts map[string]interface{}
	SpageCoreConfig  *config.Config // Pass necessary config parts
}

SpageActivityInput defines the input for our generic Spage task activity.

type SpageActivityResult

type SpageActivityResult struct {
	HostName          string
	TaskName          string
	Output            string
	Changed           bool
	Error             string // Store error message if any
	Skipped           bool
	Ignored           bool
	RegisteredVars    map[string]interface{}
	HostFactsSnapshot map[string]interface{}
}

SpageActivityResult defines the output from our generic Spage task activity.

func ExecuteSpageTaskActivity

func ExecuteSpageTaskActivity(ctx context.Context, input SpageActivityInput) (*SpageActivityResult, error)

ExecuteSpageTaskActivity is the generic activity that runs a Spage task.

func RevertSpageTaskActivity

func RevertSpageTaskActivity(ctx context.Context, input SpageActivityInput) (*SpageActivityResult, error)

RevertSpageTaskActivity is the generic activity that runs a Spage task's revert action.

type TemporalGraphExecutor

type TemporalGraphExecutor struct {
	Runner TemporalTaskRunner
}

func NewTemporalGraphExecutor

func NewTemporalGraphExecutor(runner TemporalTaskRunner) *TemporalGraphExecutor

func (*TemporalGraphExecutor) Execute

func (e *TemporalGraphExecutor) Execute(
	inventoryHosts map[string]*pkg.Host,
	workflowHostFacts map[string]map[string]interface{},
	orderedGraph [][]pkg.Task,
	cfg *config.Config,
) error

type TemporalTaskRunner

type TemporalTaskRunner struct {
	WorkflowCtx workflow.Context // The Temporal workflow context
}

TemporalTaskRunner implements the TaskRunner interface for Temporal activity execution. It requires access to the workflow.Context to execute activities. Note: This runner is conceptual for showing how Temporal fits the TaskRunner pattern. The SpageTemporalWorkflow will still manage its own execution loop due to differences in fact/state management compared to LocalGraphExecutor's assumptions.

func NewTemporalTaskRunner

func NewTemporalTaskRunner(workflowCtx workflow.Context) *TemporalTaskRunner

NewTemporalTaskRunner creates a new TemporalTaskRunner.

func (*TemporalTaskRunner) ExecuteTask

func (r *TemporalTaskRunner) ExecuteTask(execCtx workflow.Context, task pkg.Task, closure *pkg.Closure, cfg *config.Config) pkg.TaskResult

RunTask for Temporal dispatches the task as a Temporal activity. It converts the SpageActivityResult from the activity into a TaskResult. The original SpageActivityResult is stored in TaskResult.ExecutionSpecificOutput.

func (*TemporalTaskRunner) RevertTask

func (r *TemporalTaskRunner) RevertTask(execCtx workflow.Context, task pkg.Task, closure *pkg.Closure, cfg *config.Config) pkg.TaskResult

Jump to

Keyboard shortcuts

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