star

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxSteps = 100_000

DefaultMaxSteps is the instruction budget per script execution (100k instructions).

Variables

View Source
var ErrMissingExecute = errors.New("script must define an 'execute(ctx)' function")

ErrMissingExecute is returned when a script does not declare an `execute(ctx)` function.

Functions

func Eval

func Eval(source string, env Env) (any, error)

Eval executes a Starlark script against the environment using the default step budget.

func EvalWithLimit

func EvalWithLimit(source string, env Env, maxSteps uint64) (any, error)

EvalWithLimit compiles and runs a Starlark script enforcing a strict instruction limit.

func ToGo

func ToGo(val starlark.Value) any

ToGo converts Starlark values back into clean, standard Go types.

func ToValue

func ToValue(val any) starlark.Value

ToValue converts arbitrary Go primitives, slices, and maps into standard Starlark values.

Types

type CaseInsensitiveDict

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

CaseInsensitiveDict implements a Python-compatible dictionary with RFC 9110 case-insensitive lookups, sequence iteration, and dot-notation attribute access.

func NewCaseInsensitiveDict

func NewCaseInsensitiveDict(data map[string]any) *CaseInsensitiveDict

NewCaseInsensitiveDict creates an instance from an arbitrary Go map.

func NewCaseInsensitiveDictFromStrings

func NewCaseInsensitiveDictFromStrings(data map[string]string) *CaseInsensitiveDict

NewCaseInsensitiveDictFromStrings creates an instance from string-keyed headers.

func (*CaseInsensitiveDict) Attr

func (d *CaseInsensitiveDict) Attr(name string) (starlark.Value, error)

Attr implements starlark.HasAttrs. Supports `.get()`, `.keys()`, `.values()`, `.items()`, and dot-notation.

func (*CaseInsensitiveDict) AttrNames

func (d *CaseInsensitiveDict) AttrNames() []string

AttrNames implements starlark.Value.AttrNames.

func (*CaseInsensitiveDict) Freeze

func (d *CaseInsensitiveDict) Freeze()

Freeze implements starlark.Value.Freeze.

func (*CaseInsensitiveDict) Get

Get implements starlark.Mapping: supports `d["Key"]` and `"Key" in d`.

func (*CaseInsensitiveDict) Hash

func (d *CaseInsensitiveDict) Hash() (uint32, error)

Hash implements starlark.Value.Hash.

func (*CaseInsensitiveDict) Iterate

func (d *CaseInsensitiveDict) Iterate() starlark.Iterator

Iterate implements starlark.Value.Iterate.

func (*CaseInsensitiveDict) Len

func (d *CaseInsensitiveDict) Len() int

Len implements starlark.Value.Len.

func (*CaseInsensitiveDict) String

func (d *CaseInsensitiveDict) String() string

String implements starlark.Value.String.

func (*CaseInsensitiveDict) ToMap

func (d *CaseInsensitiveDict) ToMap() map[string]any

ToMap converts the CaseInsensitiveDict to a Go map.

func (*CaseInsensitiveDict) Truth

func (d *CaseInsensitiveDict) Truth() starlark.Bool

Truth implements starlark.Value.Truth.

func (*CaseInsensitiveDict) Type

func (d *CaseInsensitiveDict) Type() string

Type implements starlark.Value.Type.

type CompileError

type CompileError struct {
	Err error
}

CompileError indicates a syntax error or compilation failure in Starlark source code.

func (*CompileError) Error

func (e *CompileError) Error() string

func (*CompileError) Unwrap

func (e *CompileError) Unwrap() error

type Env

type Env struct {
	Request        Request
	Steps          map[string]map[string]any
	TimestampEpoch int64
}

Env represents the execution context envelope (`ctx`) exposed to Starlark.

type Request

type Request struct {
	Method  string
	Path    map[string]string
	Query   map[string]string
	Headers map[string]string
	Body    any
}

Request models incoming HTTP request state for Starlark scripts.

type RuntimeError

type RuntimeError struct {
	Err error
}

RuntimeError indicates an unhandled runtime exception, division by zero, or step limit breach.

func (*RuntimeError) Error

func (e *RuntimeError) Error() string

func (*RuntimeError) Unwrap

func (e *RuntimeError) Unwrap() error

Jump to

Keyboard shortcuts

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