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 ¶
const ( CapabilityProgress = "platform.progress" CapabilityResult = "platform.result" )
Binding names, as the dialect contract and Validate's capability list name them.
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 ¶
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 ¶
Log returns the captured log, marked when output was dropped, and whether it was.
func (*Live) Print ¶
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.