executor

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Overview

Package executor defines the interface that bridges tasks enqueued by the processor with the backing implementation of actions. It is effectively a glue layer between the high-level workflow model and low-level service implementations.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTaskNotFound   = errors.New("task not found in workflow")
	ErrMethodNotFound = errors.New("method not found in service")
)

Functions

func StdoutListener

func StdoutListener(task *graph.Task, input, output interface{})

StdoutListener replicates the debug prints that were hard-coded in the previous implementation. It serialises the task specification, input and output into JSON and prints them to standard output. Errors from json.Marshal are ignored on purpose – they indicate non-serialisable values and the caller would not have had access to the data either way in the original implementation.

Types

type Listener

type Listener func(task *graph.Task, exec *execution.Execution)

Listener is invoked once a task action completes (regardless of whether it returned an error or not). Implementations can log, collect metrics or perform any other side-effects they require.

For convenience the listener is defined as a function type rather than an interface; users can therefore pass a plain function literal when customising the executor.

type Option

type Option func(*service)

Option is used to customise the executor instance.

func WithApprovalService added in v0.1.1

func WithApprovalService(approval approval.Service) Option

WithApprovalService applies the approval service to the executor. The approval service is used to

func WithApprovalSkipPrefixes added in v0.1.2

func WithApprovalSkipPrefixes(prefixes ...string) Option

WithApprovalSkipPrefixes configures the executor so that actions whose fully qualified name (service.method, lower-cased) starts with any of the specified prefixes will bypass the approval request in policy ModeAsk.

func WithListener

func WithListener(l Listener) Option

WithListener overrides the listener invoked after every executed task. Passing nil disables the callback entirely.

type Service

type Service interface {
	Execute(ctx context.Context, execution *execution.Execution, process *execution.Process) error
}

Service represents a task executor.

func NewService

func NewService(actions *extension.Actions, opts ...Option) Service

NewService creates a new executor service instance.

The function is backwards-compatible with the previous signature: callers that do not require customisation can ignore the variadic options argument.

Jump to

Keyboard shortcuts

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