Documentation
¶
Overview ¶
Package daemon is pi-env's daemon: it gives a Pi Durable host an execution environment on this machine over a framed protocol on stdin and stdout, usually started through ssh as `pi-env serve --token <hex>`.
Ports packages/env/daemon/src/main.rs
Go mapping: the Rust crate is a Go package, and Serve runs one connection. The daemon reuses durable/env/node for `exec` and `watch`, which the Rust crate re-implements as ports of Durable's NodeExecutionEnv; file operations are Go standard library calls with Node's error codes from internal/nodeerrno. The wire protocol is packages/env/docs/protocol.md unchanged.
Index ¶
Constants ¶
const ( FrameRequest byte = 1 FrameResult byte = 2 FrameError byte = 3 FrameEvent byte = 4 FrameCancel byte = 5 FramePing byte = 6 )
Frame types (docs/protocol.md).
const ( // MaxFrame is the largest frame either side accepts. MaxFrame = 16 * 1024 * 1024 // MaxPayload is the largest payload a response carries, leaving room for its JSON. MaxPayload = MaxFrame - 64*1024 )
const (
// Protocol is the wire protocol version.
Protocol = 1
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Failure ¶
type Failure struct {
Code string
Message string
Syscall string
Path string
// Extra holds more fields for the client, such as spillPath.
Extra Object
}
Failure is an error with a Node-style code such as ENOENT; messages are diagnostic only.
type Frame ¶
type Frame struct {
Kind byte
ID uint32
// JSON is the decoded JSON of the frame. A frame whose JSON does not parse arrives with a nil JSON and gets an
// error reply, because the framing itself is intact.
JSON any
Payload []byte
}
Frame is one message: `u32 length | u8 type | u32 id | u32 jsonLength | json | payload`, integers big-endian.
type Options ¶
type Options struct {
// Version is what `hello` reports as version: the release the daemon shipped with.
Version string
// PingInterval and SilenceLimit default to the protocol's 5 s and 30 s.
PingInterval time.Duration
SilenceLimit time.Duration
// OnSilence runs when the client went silent for the limit, after everything it started was killed; it defaults to
// exiting the process, as the daemon does.
OnSilence func()
}
Options configure Serve.