Help us shape the future of Go! Take the 2026 Go Developer Survey

function_run

package
v0.57.30 Latest Latest
Warning

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

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

Documentation

Overview

Package function_run runs PureFunctions in the QuickJS-NG WASI reactor under wazero.

Index

Constants

View Source
const InputPlaceholder = "__PURE_FUNCTION_INPUT__"

InputPlaceholder is the token in Harness that a runner replaces with the input in protobuf JSON form.

Variables

View Source
var ErrInstructionBudget = errors.New("the function ran past its instruction budget")

ErrInstructionBudget is returned when a run passes its interrupt checks.

View Source
var ErrMemoryBudget = errors.New("the function ran past its memory budget")

ErrMemoryBudget is returned when a run passes its memory limit.

View Source
var Harness string

Harness is the module that runs a PureFunction. The browser runner evaluates the same text.

Functions

This section is empty.

Types

type FunctionError

type FunctionError struct {
	// Message is the error's string form.
	Message string
}

FunctionError is an error the function threw or returned.

func (*FunctionError) Error

func (e *FunctionError) Error() string

Error returns the error message.

type JSONMarshaler

type JSONMarshaler interface {
	MarshalJSON() ([]byte, error)
}

JSONMarshaler is a message with a protobuf JSON form, such as a generated protobuf message.

type JSONUnmarshaler

type JSONUnmarshaler interface {
	UnmarshalJSON([]byte) error
}

JSONUnmarshaler decodes a message from its protobuf JSON form.

type Runner

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

Runner runs PureFunctions, each in a fresh QuickJS instance, so one run cannot change the next and every run spends its budget from the start.

func NewRunner

func NewRunner(le *logrus.Entry, compiled wazero.CompilationCache, bytecode *bldr_util_qjsbytecode.Cache) *Runner

NewRunner returns a runner. compiled is shared with other users of the reactor, and nil keeps a cache of its own; bytecode caches function modules and nil compiles them every run.

func (*Runner) Run

Run runs fn on in and stores its result in out.

func (*Runner) RunJSON

func (r *Runner) RunJSON(ctx context.Context, fn *s4wave_function.PureFunction, input []byte) ([]byte, error)

RunJSON runs fn on the protobuf JSON input and returns its output as JSON.

Jump to

Keyboard shortcuts

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