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

scriptlive

package
v1.149.0 Latest Latest
Warning

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

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

Documentation

Overview

Package scriptlive holds what a managed-script run reports while it executes and what it hands back when it ends: the log it prints, its latest platform.progress, and the value it returns with platform.result (#1845, #1847).

One Live serves the interpreter and the reader at once. The interpreter writes to it from the run's goroutine; the worker snapshots it every few seconds from another and writes the snapshot to the run row, which is how a running run shows "120 of 500" and the log so far instead of only "running". It is the run's log itself, not a copy of it: the log a finished run records is read from the same buffer, so the live view and the final record cannot disagree about what was printed.

Index

Constants

View Source
const (
	CapabilityProgress = "platform.progress"
	CapabilityResult   = "platform.result"
)

Binding names, as the dialect contract and Validate's capability list name them.

View Source
const DefaultMaxResultBytes = 1 << 20

DefaultMaxResultBytes caps the value platform.result hands back. A result is an answer for a caller waiting on the run, not a dataset; anything larger is an output.

Variables

This section is empty.

Functions

This section is empty.

Types

type Live

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

Live is one run's reporting state. Safe for concurrent use.

func New

func New(maxLogBytes, maxResultBytes int) *Live

New returns a Live whose log holds at most maxLogBytes and whose result is at most maxResultBytes (DefaultMaxResultBytes when not positive).

func (*Live) Bindings

func (l *Live) Bindings() starlark.StringDict

Bindings are the platform members this package provides, keyed by the member name a script calls.

func (*Live) Log

func (l *Live) Log() (string, bool)

Log returns the captured log, marked when output was dropped, and whether it was.

func (*Live) Print

func (l *Live) Print(msg string)

Print appends one line to the log, stopping at the cap. The head of the log is kept: the first lines say what the run set out to do, which is what the reader of a truncated log needs.

func (*Live) Progress

func (l *Live) Progress() *script.RunProgress

Progress is the latest progress report, nil before the first.

func (*Live) Result

func (l *Live) Result() json.RawMessage

Result is the value the run returned, nil when it set none.

func (*Live) Snapshot

func (l *Live) Snapshot() (live script.RunLive, version uint64)

Snapshot is what the run has reported so far, with the version it was taken at.

Jump to

Keyboard shortcuts

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