runner

package
v0.0.0-...-7eb2361 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyRequestOptions

func ApplyRequestOptions(nodes map[idwrap.IDWrap]node.FlowNode, services RunnerServices)

ApplyRequestOptions sets each request node's stream: and follow_redirects: options from its HTTP request's settings.

func RunFlow

func RunFlow(ctx context.Context, flowPtr *mflow.Flow, services RunnerServices, reporters *reporter.ReporterGroup) (model.FlowRunResult, error)

func RunMultipleFlows

func RunMultipleFlows(ctx context.Context, fileData []byte, allFlows []mflow.Flow, services RunnerServices, logger *slog.Logger, reporters *reporter.ReporterGroup) error

RunMultipleFlows executes multiple flows based on the run field configuration. Flows run sequentially in dependency order (a topological sort of the run: block, ties broken by original list order) rather than run: block declaration order. A flow whose dependency failed, or was itself skipped, is reported as skipped instead of attempted; flows with no such gate still run even if an unrelated earlier flow failed.

Types

type Checks

type Checks struct {
	Evaluator *aicheck.Evaluator
	// contains filtered or unexported fields
}

Checks evaluates the AI checks (expect: blocks) of a command's flows after each flow runs.

func NewChecks

func NewChecks(bundle *ioworkspace.WorkspaceBundle, opts ChecksOptions) (*Checks, error)

NewChecks compiles the bundle's expect: blocks per flow. It returns nil when the file has none.

func (*Checks) Close

func (c *Checks) Close() error

Close saves the judge cache.

func (*Checks) Notices

func (c *Checks) Notices() []string

Notices are the lines printed once per command: why judge checks were skipped, and that failed checks only report.

type ChecksOptions

type ChecksOptions struct {
	// Dir resolves expect: schema paths (the flow file's directory).
	Dir string
	// CachePath is the judge cache file; "" keeps verdicts in memory only.
	CachePath string
	// Env is where judge API keys are read from.
	Env map[string]string
	// HTTP is the judge's client; nil uses a client with a 60 s timeout.
	HTTP *http.Client
}

ChecksOptions configure NewChecks.

type Cleanup

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

Cleanup is a flow's built cleanup: block, ready to run after the flow's normal steps. A nil *Cleanup (the flow has no cleanup block) runs nothing.

func BuildCleanup

func BuildCleanup(ctx context.Context, flow mflow.Flow, services RunnerServices, deps CleanupBuildDeps) (*Cleanup, error)

BuildCleanup builds the node implementations of flow's cleanup block. It returns nil when the flow has none.

func (*Cleanup) DisplayNames

func (c *Cleanup) DisplayNames() []string

DisplayNames are the cleanup step names as reporters show them.

func (*Cleanup) Nodes

func (c *Cleanup) Nodes() map[idwrap.IDWrap]node.FlowNode

Nodes returns the cleanup step nodes by ID.

func (*Cleanup) Run

func (c *Cleanup) Run(ctx context.Context, varMap map[string]any, emit func(reporter.NodeStatusEvent)) ([]model.NodeRunResult, error)

Run executes the cleanup steps one at a time, in order, against the flow's final variable map (which it extends with the cleanup steps' own outputs). Every step is attempted: a failure does not stop the steps after it. A step is skipped instead when a step it reads produced no output, or a cleanup step it depends on did not succeed.

It returns one result per step and, if any step failed, an error naming the first failure. Cleanup stops early only when ctx is cancelled (Ctrl-C).

func (*Cleanup) Size

func (c *Cleanup) Size() int

Size is the number of cleanup steps.

type CleanupBuildDeps

type CleanupBuildDeps struct {
	Timeout     time.Duration
	HTTPClient  httpclient.HttpClient
	RespChan    chan nrequest.NodeRequestSideResp
	GQLRespChan chan ngraphql.NodeGraphQLSideResp
}

CleanupBuildDeps are the per-run resources cleanup nodes share with the flow's normal nodes.

type JSRunner

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

JSRunner manages the lifecycle of the Node.js worker process

func NewJSRunner

func NewJSRunner() (*JSRunner, error)

NewJSRunner checks if Node.js is available and returns a runner instance

func (*JSRunner) Client

Client returns the RPC client for the JS executor

func (*JSRunner) Start

func (r *JSRunner) Start(ctx context.Context) error

Start starts the JS worker process and returns as soon as it answers an RPC, polling every jsWorkerPollInterval for up to jsWorkerStartupTimeout.

func (*JSRunner) Stop

func (r *JSRunner) Stop()

Stop stops the JS worker process and cleans up

type RunnerServices

type RunnerServices struct {
	NodeService         sflow.NodeService
	EdgeService         sflow.EdgeService
	FlowVariableService sflow.FlowVariableService
	Builder             *flowbuilder.Builder
	JSClient            node_js_executorv1connect.NodeJsExecutorServiceClient
	// Cleanups holds each flow's cleanup: block, keyed by owning flow ID. The
	// hidden cleanup flows must have been imported (ImportFlowCleanups).
	Cleanups map[idwrap.IDWrap]ioworkspace.FlowCleanup
	// Streams holds request steps' stream: settings, by HTTP request ID.
	Streams map[idwrap.IDWrap]mhttp.HTTPStream
	// NoRedirects holds the HTTP requests of steps with follow_redirects: false.
	NoRedirects map[idwrap.IDWrap]bool
	// Checks evaluates the flows' AI checks after each run; nil when the file has none.
	Checks *Checks
}

Jump to

Keyboard shortcuts

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