Documentation
¶
Index ¶
- Variables
- func CallLambda(ctx context.Context, val any, args []any, start time.Time, depth int) (any, error)
- func NewDebugContext(ctx context.Context) (context.Context, *[]DebugEntry)
- func ToBool(v any) bool
- func ToFloat(v any) float64
- func ToInt(v any) int64
- func ToString(v any) string
- type BuiltinFunc
- type CompiledFunction
- type DebugEntry
- type ExecConfig
- type Executor
- type FunctionLookup
Constants ¶
This section is empty.
Variables ¶
var ( ErrTimeout = errors.New("execution timeout exceeded") ErrMaxDepth = errors.New("maximum call depth exceeded") ErrDivZero = errors.New("division by zero") )
Errors returned by the executor.
var ErrUserRaise = errors.New("raise")
ErrUserRaise is returned when a DTL function executes a raise statement.
Functions ¶
func CallLambda ¶
CallLambda invokes a lambda closure. Used by stdlib collection functions.
func NewDebugContext ¶
func NewDebugContext(ctx context.Context) (context.Context, *[]DebugEntry)
NewDebugContext returns a context with an attached debug buffer.
Types ¶
type BuiltinFunc ¶
type BuiltinFunc struct {
Name string
MinArgs int
MaxArgs int // -1 for variadic
Fn func(args []any) (any, error)
// CtxFn is an optional context-aware alternative to Fn.
// When set, the executor passes the evaluation context so the function
// can access platform services (schema, query, pipeline, etc.).
// If CtxFn is set, Fn is ignored.
CtxFn func(ctx context.Context, args []any) (any, error)
}
BuiltinFunc is a Go-implemented function callable from DTL.
type CompiledFunction ¶
CompiledFunction is a parsed+compiled user-defined function ready for execution.
type DebugEntry ¶
type DebugEntry struct {
Timestamp time.Time `json:"timestamp"`
Label string `json:"label,omitempty"`
Values []any `json:"values"`
}
DebugEntry represents a single debug/print output line.
type ExecConfig ¶
ExecConfig holds execution limits.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor evaluates compiled DTL AST nodes via tree-walking.
func New ¶
func New(builtins map[string]*BuiltinFunc, lookup FunctionLookup, config ExecConfig) *Executor
New creates an executor with the given built-ins and function resolver.
type FunctionLookup ¶
type FunctionLookup interface {
GetCompiled(ctx context.Context, name string) (*CompiledFunction, bool)
}
FunctionLookup resolves function names to compiled user functions.