Documentation
¶
Overview ¶
Package runtime is linked into every compiled notebook. The kernel starts the notebook's binary as a worker and drives it through Serve: it asks the worker to run a cell, to hand over the value of a notebook variable, or to take one back after a rebuild, so that cells whose code and inputs did not change are not run again.
The protocol is one JSON object per line on the worker's standard input and output. What a cell prints goes to a pipe of its own, so it can never be mistaken for a reply.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bundle ¶
Bundle returns the MIME bundle of a value: its own when it implements Displayer, else its fmt %v text. A Displayer without text/plain (a figure that is only SVG and PNG) gets its type, <*plot.Figure>, rather than the %v of its innards.
Types ¶
type Cell ¶
type Cell struct {
// contains filtered or unexported fields
}
Cell is handed to each compiled cell; the generated code calls Show with the cell's final expression.
type Displayer ¶
Displayer is implemented by values that know how to show themselves: the result maps a MIME type ("text/plain", "text/html", "image/svg+xml", "image/png", ...) to the bytes of that representation.
type Program ¶
type Program struct {
// Cells holds the compiled cells by their index among the notebook's
// code cells; a cell that defines nothing and shows nothing still has
// an entry.
Cells []func(*Cell)
// Vars maps each notebook variable to a pointer to it.
Vars map[string]any
}
Program is what the generated main hands to Serve.
type Reply ¶
type Reply struct {
Cell int `json:"cell,omitempty"`
Name string `json:"name,omitempty"`
Output string `json:"output,omitempty"` // what the cell printed
Display []map[string][]byte `json:"display,omitempty"` // what it showed
Error string `json:"error,omitempty"` // a panic, with its stack
Took time.Duration `json:"took,omitempty"` // how long the cell ran, in the worker
Data []byte `json:"data,omitempty"` // an encoded value
// Volatile reports a value that cannot be encoded (a func, a channel,
// unexported state): the cell that makes it has to run again instead.
Volatile bool `json:"volatile,omitempty"`
}
Reply answers a Request.