models

package
v1.3.26 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 16 Imported by: ? 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 models runs external Starlark models over an already connected device.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidName = errors.New("invalid model name")
	ErrNotFound    = errors.New("model not found")
)

Functions

This section is empty.

Types

type Executor

type Executor interface {
	ExecuteCtx(context.Context, cmd.Cmd) (cmd.CmdRes, error)
}

Executor is the command-execution subset of device.Device. The caller owns the connection; concurrent calls must not share a device unless it supports it.

type Option

type Option func(*Runner)

func WithCommandOptions

func WithCommandOptions(opts ...cmd.CmdOption) Option

WithCommandOptions supplies defaults to every command executed by a model.

func WithMaxExecutionSteps

func WithMaxExecutionSteps(steps uint64) Option

WithMaxExecutionSteps sets the per-collection budget, including imports.

type Runner

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

Runner is safe for concurrent use. Source files are reloaded on every call.

func New

func New(directory string, opts ...Option) (*Runner, error)

func (*Runner) Check

func (r *Runner) Check(name string) error

Check validates a model name and that its source is readable inside the root. It performs no evaluation and does not access a device.

func (*Runner) Collect

func (r *Runner) Collect(ctx context.Context, dev Executor, deviceType, name string) (json.RawMessage, error)

Collect executes <name>.star's collect(device) and returns a JSON object. Neither Connect nor Close is called here. No partial result is returned.

Jump to

Keyboard shortcuts

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