expr

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package expr compiles and evaluates the expressions used by flow definitions: choice predicates (`when:`), map sources (`over:`), subflow inputs, search attributes and concurrency keys. Expressions are written in expr-lang and evaluated against the execution's context view:

input      the start payload
channels   the reduced state channels
results    each settled node's latest output, keyed by node id
last_node  the most recently settled node
visits     how many times each node was entered
signals    consumed signal payloads, keyed by signal name
branches   branch status of the current fan-out, keyed by branch id
counters   generic usage counters
item/index the current element of a map node (map instances only)

Expressions are restricted to a bounded, straight-line subset (see validateBudgetedProgram): flow authors are not fully trusted, and expr has no preemptive VM deadline.

Index

Constants

View Source
const (
	VarInput    = "input"
	VarChannels = "channels"
	VarResults  = "results"
	VarLastNode = "last_node"
	VarVisits   = "visits"
	VarSignals  = "signals"
	VarBranches = "branches"
	VarCounters = "counters"
	VarErrors   = "errors"
	VarItem     = "item"
	VarIndex    = "index"
)

Context view variable names.

Variables

This section is empty.

Functions

This section is empty.

Types

type Program

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

Program is a compiled expression.

func CompilePredicate

func CompilePredicate(code string) (*Program, error)

CompilePredicate compiles a boolean expression (a choice rule).

func CompileValue

func CompileValue(code string) (*Program, error)

CompileValue compiles an expression producing any value (map `over`, subflow `input`, search attributes, concurrency keys).

func (*Program) Eval

func (p *Program) Eval(ctx context.Context, env map[string]any) (any, error)

Eval evaluates the program against env (a context view as produced by the fold). ctx is checked before and after evaluation; the compile-time restrictions are the primary CPU bound.

func (*Program) Match

func (p *Program) Match(ctx context.Context, env map[string]any) (bool, error)

Match evaluates a predicate. A false result and a non-nil error are returned when evaluation fails (e.g. a referenced field is missing); callers decide whether that means "no match" or a failure (choice on_error).

func (*Program) String

func (p *Program) String() string

String returns the source of the expression.

Jump to

Keyboard shortcuts

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