engine

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CfgBool

func CfgBool(cfg map[string]any, key string, def bool) bool

CfgBool reads a boolean config value with a default.

func CfgInt

func CfgInt(cfg map[string]any, key string, def int) int

CfgInt reads an integer config value with a default.

func Register

func Register(name string, e Executor)

Register makes a node type available to workflows. Call from a node's init().

Types

type Executor

type Executor func(ctx context.Context, rc *RunContext, cfg map[string]any) (map[string]any, error)

Executor runs a single step. cfg is the step's raw config map; the returned map becomes the step's result, addressable in later templates as ".<stepID>".

type RunContext

type RunContext struct {
	Vars    map[string]any
	Results map[string]any
}

RunContext carries variables and accumulated step results through a run.

func NewRunContext

func NewRunContext(vars map[string]any) *RunContext

NewRunContext creates an empty run context seeded with vars.

func (*RunContext) Render

func (rc *RunContext) Render(s string) (string, error)

Render expands Go template syntax ({{ .stepID.field }}, {{ .vars.x }}) in s against the current run state. Strings without "{{" are returned unchanged.

func (*RunContext) String

func (rc *RunContext) String(cfg map[string]any, key, def string) (string, error)

String returns a rendered string config value, or def if absent.

type Step

type Step struct {
	ID     string         `yaml:"id"`
	Type   string         `yaml:"type"`
	Config map[string]any `yaml:"config"`
}

Step is a single unit of work in a workflow. Type selects a registered node executor; Config is passed to it verbatim (string fields support Go templates).

type Workflow

type Workflow struct {
	Name        string         `yaml:"name"`
	Description string         `yaml:"description"`
	Vars        map[string]any `yaml:"vars"`
	Steps       []Step         `yaml:"steps"`
}

Workflow is a named, ordered list of steps plus initial variables.

func Load

func Load(path string) (*Workflow, error)

Load reads and validates a workflow from a YAML file.

func (*Workflow) Run

func (w *Workflow) Run(ctx context.Context) (*RunContext, error)

Run executes every step in order, threading results through a shared context. It stops at the first error and returns the partial context for inspection.

Jump to

Keyboard shortcuts

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