flow

package
v0.1.0-dev.20260308222923 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package flow implements flow-control actions for execution graphs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Choose

type Choose struct{}

Choose is a conditional branch selector. It reads a boolean from its "when" slot and executes either the "then" or "else" phase.

Slots:

  • when: bool — condition (resolved from a predicate action's output)
  • then: string — phase ID to execute when true
  • else: string — phase ID to execute when false (optional)

Result: the selected branch phase's terminal node Result. Complement: *chooseComplement — the branch's recovery entries.

func (*Choose) Do

func (a *Choose) Do(ctx *op.Context, slots map[string]any) (result op.Result, complement op.Complement, err error)

Do reads the boolean condition and executes the matching branch phase.

func (*Choose) Name

func (a *Choose) Name() string

Name returns the dotted action name.

func (*Choose) Params

func (a *Choose) Params() []op.ParamInfo

Params returns nil — Choose uses untyped slots.

func (*Choose) Undo

func (a *Choose) Undo(_ *op.Context, complement op.Complement) error

Undo unwinds the selected branch's recovery stack in LIFO order.

type Complete

type Complete struct{}

Complete is the default, healthy conclusion of a graph path. Leaf node — nothing depends on it. Accepts an optional output value that can be captured by the graph consumer.

func (*Complete) Do

func (a *Complete) Do(_ *op.Context, slots map[string]any) (op.Result, op.Complement, error)

Do returns the output slot value. Not compensable — a successful terminal has nothing to undo.

func (*Complete) Name

func (a *Complete) Name() string

Name returns the dotted action name.

func (*Complete) Params

func (a *Complete) Params() []op.ParamInfo

Params returns nil — Complete uses untyped slots.

type Degraded

type Degraded struct{}

Degraded is a terminal leaf node that marks a branch as non-optimal while allowing graph execution to continue. It formats a Go template message from its slots, writes to stderr, and returns the rendered warning as the node output.

func (*Degraded) Do

func (a *Degraded) Do(_ *op.Context, slots map[string]any) (op.Result, op.Complement, error)

Do formats the template message and writes it to stderr. Returns the rendered warning as the node output with nil error — graph continues. Not compensable — a warning has no side effect to undo.

func (*Degraded) Name

func (a *Degraded) Name() string

Name returns the dotted action name.

func (*Degraded) Params

func (a *Degraded) Params() []op.ParamInfo

Params returns nil — Degraded uses untyped slots.

type Elevate

type Elevate struct{}

Elevate is a privilege transition flow action. It marks the boundary between unprivileged and privileged execution as an explicit graph node. In dry-run mode it reports "root required here"; the receipt records when privilege was acquired and released.

func (*Elevate) Do

func (a *Elevate) Do(_ *op.Context, _ map[string]any) (op.Result, op.Complement, error)

Do acquires elevated privilege. Stub implementation — full sudo/privilege integration is a separate plan.

func (*Elevate) Name

func (a *Elevate) Name() string

Name returns the dotted action name.

func (*Elevate) Params

func (a *Elevate) Params() []op.ParamInfo

Params returns nil — Elevate takes no typed parameters.

type Fatal

type Fatal struct{}

Fatal is a terminal leaf node that halts graph execution immediately. Same signature as Degraded — a Go template format string with args/kwargs. The executor detects FatalError and stops.

func (*Fatal) Do

func (a *Fatal) Do(_ *op.Context, slots map[string]any) (op.Result, op.Complement, error)

Do formats the template message and returns a FatalError. Not compensable — prior nodes unwind via the existing recovery stack.

func (*Fatal) Name

func (a *Fatal) Name() string

Name returns the dotted action name.

func (*Fatal) Params

func (a *Fatal) Params() []op.ParamInfo

Params returns nil — Fatal uses untyped slots.

type FlowPlan

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

FlowPlan implements the plan.flow namespace for Starlark scripts. Handwritten — flow actions have custom signatures that don't fit the reflection-based WrapPlanned model.

func NewFlowPlan

func NewFlowPlan(graph *op.Graph, project string, reg *op.ActionRegistry) *FlowPlan

NewFlowPlan creates a plan.flow namespace bound to the given graph.

func (*FlowPlan) Attr

func (f *FlowPlan) Attr(name string) (starlark.Value, error)

Attr implements starlark.HasAttrs.

func (*FlowPlan) AttrNames

func (f *FlowPlan) AttrNames() []string

AttrNames implements starlark.HasAttrs.

func (*FlowPlan) Freeze

func (f *FlowPlan) Freeze()

func (*FlowPlan) Hash

func (f *FlowPlan) Hash() (uint32, error)

func (*FlowPlan) String

func (f *FlowPlan) String() string

func (*FlowPlan) Truth

func (f *FlowPlan) Truth() starlark.Bool

func (*FlowPlan) Type

func (f *FlowPlan) Type() string

type Gather

type Gather struct{}

Gather is a parallel comprehension flow action. It executes a phase body once per item with configurable concurrency, collecting terminal results.

Slots:

  • items: []any — the list of items to iterate over
  • do: string — phase ID of the body to execute per item
  • limit: int — max concurrent iterations (default 1 = sequential)

Result: []any — terminal node Result from each iteration, in item order. Complement: *gatherComplement — per-iteration entries for rollback.

func (*Gather) Do

func (a *Gather) Do(ctx *op.Context, slots map[string]any) (result op.Result, complement op.Complement, err error)

Do executes the referenced phase once per item, with per-iteration isolation.

func (*Gather) Name

func (a *Gather) Name() string

Name returns the dotted action name.

func (*Gather) Params

func (a *Gather) Params() []op.ParamInfo

Params returns nil — Gather uses untyped slots.

func (*Gather) Undo

func (a *Gather) Undo(ctx *op.Context, complement op.Complement) error

Undo walks iterations in reverse and calls Action.Undo per entry.

type PredicateFunc

type PredicateFunc func(any) (bool, error)

PredicateFunc is a re-evaluable condition for polling actions.

type WaitUntil

type WaitUntil struct{}

WaitUntil is an event-driven sensor — a synchronization primitive that pauses execution until a condition is satisfied or a timeout expires.

Slots:

  • target: any — the value to evaluate the predicate against (typically a promise)
  • predicate: PredicateFunc — condition to evaluate
  • timeout: string — maximum wait time (Go duration, e.g. "5m")
  • interval: string — poll interval (Go duration, default "5s")

Result: the target value when the predicate returns true.

func (*WaitUntil) Do

func (a *WaitUntil) Do(ctx *op.Context, slots map[string]any) (op.Result, op.Complement, error)

Do polls the predicate at the configured interval until it returns true or the timeout expires.

func (*WaitUntil) Name

func (a *WaitUntil) Name() string

Name returns the dotted action name.

func (*WaitUntil) Params

func (a *WaitUntil) Params() []op.ParamInfo

Params returns nil — WaitUntil uses untyped slots.

Jump to

Keyboard shortcuts

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