starlark_type

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromGo added in v0.19.2

func FromGo(v any) (starlark.Value, error)

FromGo converts application Go data to Starlark. In addition to the plugin value set it accepts the named map types used by HTTP requests.

func FromPlugin added in v0.19.2

func FromPlugin(v any, depth int, funcRefFn FuncRefValueFunc) (starlark.Value, error)

FromPlugin converts a plugin SDK return value to Starlark.

func FromWire added in v0.19.2

func FromWire(v *pb.StarValue, cursorFn CursorValueFunc, funcRefFn WireFuncRefFunc, depth int) (starlark.Value, error)

FromWire converts a wire value into a starlark value. Typed structs become StarlarkType values (attribute access, mutable fields), matching what in-process plugins return. Cursors are materialized via cursorFn; a nil cursorFn rejects cursors (e.g. in constants).

func ToGo added in v0.19.2

func ToGo(v starlark.Value) (any, error)

ToGo converts a Starlark value to application-friendly Go data for JSON, templates, configuration, and schema values. It intentionally retains the established application contract: integers are int, homogeneous lists are specialized (for example []string), and typed values become plain maps.

func ToPlugin added in v0.19.2

func ToPlugin(v starlark.Value, depth int) (any, error)

ToPlugin converts a Starlark value to the plugin SDK representation while preserving Starlark-specific types such as tuples, sets, ordered dicts, large integers, and typed structs.

func ToWire added in v0.19.2

func ToWire(v starlark.Value, depth int) (*pb.StarValue, error)

ToWire converts a starlark value into its wire representation for a plugin provider call, in a single pass with no intermediate Go value tree. Fidelity notes: int64-representable ints use the int fast path and larger ints go as big ints; int and float stay distinct; tuple/set/bytes are preserved; dict entries keep insertion order; StarlarkType values become typed structs.

Types

type CursorValueFunc added in v0.19.2

type CursorValueFunc func(cursor *pb.Cursor) (starlark.Value, error)

CursorValueFunc materializes a wire cursor handle into a starlark value; supplied by the remote call path, which knows the session and provider.

type DownloadStream added in v0.18.7

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

DownloadStream is an opaque starlark value carrying a lazily produced download body. Only plugin Go code can construct one; app starlark code can just pass it through into ace.response(data=..., download=...) - it exposes no attributes, so a handler cannot fabricate or inspect one. The producer is invoked by the download response handler at response-write time, writing the body into the response buffer: the payload is never fully materialized in memory or staged to disk, and once the buffer fills a stalled client blocks the producer (TCP backpressure). Single use: a second Produce errors instead of silently sending an empty body.

func NewDownloadStream added in v0.18.7

func NewDownloadStream(name string, producer func(w io.Writer) error) *DownloadStream

func (*DownloadStream) Freeze added in v0.18.7

func (d *DownloadStream) Freeze()

Freeze is a no-op: the value is consumed by the single request thread that created it, never shared across starlark threads

func (*DownloadStream) Hash added in v0.18.7

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

func (*DownloadStream) Name added in v0.18.7

func (d *DownloadStream) Name() string

Name is the download attachment file name

func (*DownloadStream) Produce added in v0.18.7

func (d *DownloadStream) Produce(w io.Writer) error

Produce writes the body to w. It may block on w (the response writer) when the client is slow to read

func (*DownloadStream) String added in v0.18.7

func (d *DownloadStream) String() string

func (*DownloadStream) Truth added in v0.18.7

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

func (*DownloadStream) Type added in v0.18.7

func (d *DownloadStream) Type() string

type FuncRefValueFunc added in v0.19.2

type FuncRefValueFunc func(ref *sdk.FuncRef) (starlark.Value, error)

FuncRefValueFunc materializes an SDK function reference as a Starlark callable. It is supplied by plugin dispatch, which owns the module and session needed to invoke the reference.

type GoValuer added in v0.19.2

type GoValuer interface {
	ToGoValue() (any, error)
}

GoValuer converts a custom Starlark value to its application Go representation.

type Index

type Index struct {
	Fields []string
	Unique bool
}

type Output

type Output struct {
	Value starlark.Value
	Err   string
}

func (Output) Attr

func (o Output) Attr(name string) (starlark.Value, error)

func (Output) AttrNames

func (o Output) AttrNames() []string

func (Output) Freeze

func (o Output) Freeze()

func (Output) Hash

func (o Output) Hash() (uint32, error)

func (Output) String

func (o Output) String() string

func (Output) Truth

func (o Output) Truth() starlark.Bool

func (Output) Type

func (o Output) Type() string

type PluginValuer added in v0.19.2

type PluginValuer interface {
	ToPluginValue(depth int) (any, error)
}

PluginValuer converts a custom Starlark value to its plugin SDK representation, for values passed from one plugin call into another.

type Request

type Request struct {
	AppName     string
	AppPath     string
	AppUrl      string
	PagePath    string
	PageUrl     string
	Method      string
	IsDev       bool
	IsPartial   bool
	PushEvents  bool
	HtmxVersion string
	// Headers is the sanitized request header view exposed as req.Headers. It
	// is built lazily by HeadersFunc on first access, since most handlers never
	// read headers and cloning the whole header map per request is expensive.
	// Set Headers directly (with HeadersFunc nil) when the value is already
	// known.
	Headers        http.Header
	HeadersFunc    func() http.Header
	RemoteIP       string
	UrlParams      map[string]string
	Form           url.Values
	Query          url.Values
	PostForm       url.Values
	UserId         string
	UserSubject    string
	UserEmail      string
	CustomPerms    []string
	AppRBACEnabled bool
	Data           any
}

Request is a starlark.Value that represents an HTTP request. A Request is created from the Go http.Request and passed to the starlark handler function as it only argument. The Data field is updated with the handler's response and then the template evaluation is done with the same Request

func (Request) Attr

func (r Request) Attr(name string) (starlark.Value, error)

func (Request) AttrNames

func (r Request) AttrNames() []string

func (Request) Freeze

func (r Request) Freeze()

func (Request) Hash

func (r Request) Hash() (uint32, error)

func (Request) String

func (r Request) String() string

func (Request) Truth

func (r Request) Truth() starlark.Bool

func (Request) Type

func (r Request) Type() string

type StarlarkType

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

StarlarkType represents a Starlark type created from the schema type definition.

func NewStarlarkType

func NewStarlarkType(name string, data map[string]starlark.Value) *StarlarkType

func (*StarlarkType) Attr

func (s *StarlarkType) Attr(attr string) (starlark.Value, error)

func (*StarlarkType) AttrNames

func (s *StarlarkType) AttrNames() []string

func (*StarlarkType) Freeze

func (s *StarlarkType) Freeze()

func (*StarlarkType) Hash

func (s *StarlarkType) Hash() (uint32, error)

func (*StarlarkType) SetField

func (s *StarlarkType) SetField(name string, val starlark.Value) error

func (*StarlarkType) String

func (s *StarlarkType) String() string

func (*StarlarkType) Truth

func (s *StarlarkType) Truth() starlark.Bool

func (*StarlarkType) Type

func (s *StarlarkType) Type() string

type StoreField

type StoreField struct {
	Name    string
	Type    TypeName
	Default any
}

type StoreInfo

type StoreInfo struct {
	Bytes []byte // The raw bytes for the schema.star file
	Types []StoreType
}

type StoreType

type StoreType struct {
	Name    string
	Fields  []StoreField
	Indexes []Index
}

type TypeBuilder

type TypeBuilder struct {
	Name   string
	Fields []StoreField
}

func (*TypeBuilder) CreateType

func (s *TypeBuilder) CreateType(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

type TypeName

type TypeName string
const (
	INT      TypeName = "INT"
	FLOAT    TypeName = "FLOAT"
	DATETIME TypeName = "DATETIME"
	STRING   TypeName = "STRING"
	BOOLEAN  TypeName = "BOOLEAN"
	LIST     TypeName = "LIST"
	DICT     TypeName = "DICT"
)

type WireFuncRefFunc added in v0.19.2

type WireFuncRefFunc func(ref *pb.FuncRef) (starlark.Value, error)

WireFuncRefFunc materializes a wire func ref into a starlark callable that dispatches the referenced plugin function; supplied by the remote call path. A nil WireFuncRefFunc rejects func refs (e.g. in constants).

Jump to

Keyboard shortcuts

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