graph

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT 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 int

BackoffStrategy selects how the delay between retry attempts grows. All three start from RetryConfig.Delay as the baseline.

const (
	// BackoffConstant sleeps Delay between every pair of attempts.
	BackoffConstant BackoffStrategy = iota
	// BackoffLinear sleeps Delay * attemptNumber.
	BackoffLinear
	// BackoffExponential sleeps Delay * 2^(attemptNumber-1).
	BackoffExponential
)

type Graph

type Graph struct {
	Nodes map[NodeID]*Node
	Order []NodeID // topological execution order
}

Graph holds the dependency graph built from a parsed scenario.

func Build

func Build(ps *parser.ParsedScenario) (*Graph, error)

Build constructs a dependency graph from a parsed scenario.

type Node

type Node struct {
	ID           NodeID
	Kind         NodeKind
	ActionType   string // "sql", "cmd", "http", etc.
	Body         hcl.Body
	Dependencies []NodeID
	// ComponentKey links component-scoped actions back to their parent.
	// Empty for scenario-level actions.
	ComponentKey string
	// ProviderAlias is the scenario-local provider name picked via the
	// `provider = "<alias>"` reserved action attribute. Empty when
	// the scenario does not specify one; the engine's routing then
	// requires exactly one candidate to be unambiguous.
	ProviderAlias string
	// Timeout bounds the action's execute call. Zero means no
	// engine-imposed deadline (the caller's ctx still applies).
	// Set via `timeout = "30s"` in the action body.
	Timeout time.Duration
	// Retry captures a `retry { ... }` block on the action. nil
	// means no retries — the engine calls the provider exactly
	// once. When non-nil, the engine retries failed attempts with
	// the configured backoff.
	Retry *RetryConfig

	// Teardown holds the body of a `lifecycle { teardown { ... } }`
	// block if the action declares one. The body uses the same
	// schema as the outer action body (provider-validated), so a
	// sql action's teardown declares `query`, an http action's
	// declares `method` and `url`, and so on.
	//
	// nil means the action has no teardown operation. Orchard's
	// `orchard teardown <record>` command walks actions with
	// non-nil Teardown in reverse topological order; actions with
	// no Teardown are skipped.
	Teardown hcl.Body

	// ManagedTeardown is `lifecycle { managed_teardown = ... }`: nil
	// when unset, so the provider decides whether to record an undo (a
	// typed insert deletes its row; a typed update restores rows it
	// owns); false to opt out; true to ask for an undo even where the
	// provider wouldn't record one by default (restoring rows a typed
	// update changed that Orchard didn't create).
	ManagedTeardown *bool

	// SourceRange locates the action's definition in its source
	// file. Non-zero when the body was parsed from HCL text (the
	// common case) and used by the engine to decorate runtime
	// errors with `filename:line` so failures point at a specific
	// scenario line rather than a bare node ID.
	SourceRange hcl.Range

	// Instance is set when the action was expanded by count /
	// for_each; its count.* / each.* namespace is in scope for the
	// action body and teardown. nil for a plain action.
	Instance *parser.Instance
}

Node is a unit of work in the execution graph.

type NodeID

type NodeID string

NodeID uniquely identifies a node in the execution graph.

type NodeKind

type NodeKind int

NodeKind distinguishes action nodes from component nodes.

const (
	ActionNode NodeKind = iota
	ComponentNode
)

type RetryConfig

type RetryConfig struct {
	MaxAttempts int
	Delay       time.Duration
	Backoff     BackoffStrategy
	MaxDelay    time.Duration // zero = no cap
}

RetryConfig captures a `retry { ... }` block on an action. The engine treats nil as "no retry" and uses the contents to drive a bounded retry loop around the provider call.

Jump to

Keyboard shortcuts

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