Skip to main content

Module session

Module session 

Source
Expand description

The in-VM client, with the reqwest backend and the sockets.

Modules§

complete
Run one command to exactly one result: Session::run_to_completion.
exec
The exec handle and the cursor-driven stream, with the production exec id.
files
File and tar transfer. Four routes, opaque bodies, one query type.
forward
A local TCP listener that forwards HTTP and WebSocket traffic to one guest port.
http
The HTTP seam and the production backend.
keepalive
Keeping a VM awake from outside while work runs inside it.
proxy
The two-header proxy auth and the mint schedule, on tokio’s clock in production.
serve
The serving loops behind microvm tunnel and microvm port-forward, and behind the SDKs’ tunnel and port-forward handles (#263).
shell
The client half of microvm shell: a real PTY carried over the endpoint’s shell WebSocket. Issue #69, Option B — a thin client over the platform’s session, not a line-mode wrapper over exec.
split
One exec’s output as two byte channels, stdout and stderr.
sse
Incremental Server-Sent Events parsing, and the typed events the daemon emits.
tunnel
The client half of the TCP relay: a local TCP connection carried over a WebSocket.

Structs§

ClientDeadline
What the client did when its own deadline expired (BIND-9, BIND-10).
CompletionOptions
The knobs of a run-to-completion call.
CompletionPlan
A validated run-to-completion call, separable from the start request it was planned for.
ExecHandle
One exec, addressed by its caller-minted id.
ExecResult
An exec’s phase and, once it has one, its outcome.
ForwardClient
The HTTP client a forwarder’s hops go through.
ForwardSpec
Where the forwarder listens and what it forwards to.
Frame
One complete SSE frame: its event name and its raw data: text.
GapLog
The gaps a split drive has recorded so far, shared with the drive.
HttpRequest
One request, already fully addressed: absolute URL, every header, whole body.
HttpResponse
One response, body already collected.
KeepAwake
A keepalive’s policy. Build with KeepAwake::new, check with KeepAwake::validate.
KeepAwakeReport
What a finished keepalive did.
KeepAwakeTask
A keepalive running as a background task. Dropping it stops the task.
OutputGap
One byte range the daemon couldn’t replay, under GapPolicy::Event.
ProxyAuth
Mints, caches, and refreshes the proxy token for one MicroVM and one port.
ProxyToken
The minted token, as the control plane returns it: a map of header name to value.
ReqwestBackend
The production backend: one pooled reqwest client.
Session
The control API of one running MicroVM.
SessionBuilder
Builds a Session. See Session::builder.
Split
One exec’s output as two channels, and the drive that fills them.
SseParser
Feed bytes, get whole frames out. Holds a partial frame across feeds.
StreamEnd
Why a stream stopped, and where a resume would pick up.
StreamOptions
How a stream should behave. See ExecHandle::stream_with.
TokioClock
The production clock: tokio’s monotonic clock and the system’s wall clock.
Transport
The transport: a backend, the agent token, and the proxy auth every request needs.

Enums§

EndReason
The three ways a stream ends without an error.
ExecEvent
One decoded stream event.
ForwardEvent
What the forwarder did, for a caller that wants to report progress.
GapPolicy
What a split drive does when the daemon reports evicted output. See the module docs.
KeepAwakeEnd
Why a keepalive ended without an error.
KillAnswer
The daemon’s answer to the kill the client sent when its deadline expired.
TunnelEnd
What ended a tunnel, and whether the caller should treat it as a failure.

Constants§

DEFAULT_AGENT_PORT
The port the daemon listens on in the images this repo builds (AGENTD_PORT).
DEFAULT_BOOTSTRAP_TIMEOUT
How long to wait for a daemon to report bootstrapped, once its VM is RUNNING: the wait crate::sandbox::Sandbox::run makes after the RUNNING one, and Session::wait_until_ready’s default in the bindings.
DEFAULT_CLIENT_GRACE
The default CompletionOptions::client_grace: how long past the daemon’s own deadline the client waits before it kills, and how long it then waits for the killed exec’s result.
DEFAULT_EXCHANGE_TIMEOUT
How long one proxied exchange may take before it is abandoned.
DEFAULT_EXEC_WAIT
The deadline the bindings pass to ExecHandle::wait, ExecHandle::wait_and_ack and a one-shot Session::run_sync when their caller names none: five minutes, the Python client’s figure. Those methods take a deadline, so core itself never reads this; it’s here so both bindings default to one figure.
DEFAULT_READY_TIMEOUTDeprecated
The old name of DEFAULT_BOOTSTRAP_TIMEOUT, kept for one release.
DEFAULT_REFRESH_AFTER
When to re-mint: half MAX_TOKEN_LIFETIME. See the module docs for why not fifty-nine minutes.
DEFAULT_REQUEST_TIMEOUT
How long one non-streaming request may take.
MAX_TOKEN_LIFETIME
The ceiling the service enforces on a proxy token’s life. Not a choice.
NO_TIMEOUT_CEILING
The client deadline of a request with no timeout_sec: the longest a MicroVM can live (MAX_DURATION_SEC), since no command outlives the VM it runs in.
PROXY_AUTH_HEADER
The header carrying the minted JWE. One of the two keys read out of the authToken map.
PROXY_PORT_HEADER
The header naming which of the token’s allowed ports this request targets.
TIMED_OUT_EXIT_CODE
The exit code GNU timeout(1) reports for a command its deadline ended, and the one ExecResult::posix_exit_code reports for a deadline (BIND-6).
TUNNEL_CHUNK_BYTES
Bytes read from the local connection per relayed frame.
WS_AUTH_SUBPROTOCOL_PREFIX
The prefix the JWE rides behind in a WebSocket handshake.
WS_PORT_SUBPROTOCOL_PREFIX
The prefix the target port rides behind in a WebSocket handshake.
WS_SUBPROTOCOL
The base subprotocol every MicroVM WebSocket handshake offers first.

Traits§

ChunkSource
A body arriving in pieces.
Clock
The clock a refresh boundary is measured on. It’s the crate’s one Clock, and the production one is tokio’s (TokioClock, in microvms-edges): a token timed on std::time::Instant would never re-mint inside a simulation. Time, injectable so a wait or a refresh boundary is a test rather than a wait.
HttpBackend
The seam. Production and simulated transports implement this.
TokenMinter
Mints a proxy token. One method, so a test needs no AWS.

Functions§

exec_id_at
A fresh exec id for the wall time unix, since the epoch: x- plus 16 hex characters, the Python client’s shape.
explain_close
A sentence for a close code, or None when the code explains nothing.
forwards_request_header
Whether a header from the local client is forwarded upstream.
mint_exec_id
A fresh exec id from the production clock: x- plus 16 hex characters.
refusal_explanation
The 403-vs-502 sentence, or None for a status that needs no explaining.
relay_connection
Opens a tunnel to guest_port and relays local over it until either side closes.
tunnel_url
The wss:// URL for a tunnel to guest_port.
upstream_url
The absolute URL a proxied request targets, given the endpoint and the request target.

Type Aliases§

OpenStream
A streaming response: the head, and the body still to arrive.
OutputFlow
What an OutputSink answers: a boxed future of continue-or-stop, named so a caller needs no futures crate to spell it.
OutputSink
A callback for output. Only ExecEvent::Output is delivered; the result carries the exit status. Answering std::ops::ControlFlow::Break stops delivery, and the call still waits for and acks the exec, so nothing is left running unobserved (BIND-8).
RunningGate
Whether the VM behind a keepalive is still one it may poll. See the module docs.
SharedBackend
A backend behind an Arc, which is what a crate::session::Session holds.
SplitItem
What a channel carries: a chunk of one side’s bytes, or the error that ended it.