Skip to main content

Module session

Module session 

Source
Expand description

The in-VM client: one MicroVM’s control API, with the proxy auth handled for you.

Talks to agentd through the endpoint proxy — the minted proxy token read from the auth-token header map and both proxy headers on every request (TRAP-7), minting inside the retry path below the sixty-minute ceiling (TRAP-9), and the byte-offset cursor that makes an interrupted output stream resumable.

§A session holds no state worth keeping

Every exec record, every file, and the bootstrap token live in the VM. So a Session rebuilt from an endpoint and an agent token reattaches to everything a previous process was doing, and ExecHandle rebuilt from an exec id addresses the same server-side exec. That is a property of the protocol rather than of this type, and it is why the exec id is caller-minted.

§The wire types are the daemon’s

Every request body and response shape comes from the protocol crate, which the daemon also compiles against (ARCH-2). There is deliberately no mirror here: a field renamed on the daemon side breaks this build, which is the earliest and cheapest place a protocol change can fail.

§Layout

proxy is the two-header auth and the mint schedule. http is the transport seam. sse is the frame parser and the typed events. exec is the handle and the cursor-driven stream. files is file and tar transfer. The sockets (the port forwarder, the TCP tunnel, the interactive shell) and the reqwest backend are in microvms-edges, and microvms_core::session re-exports them beside these.

Re-exports§

pub use complete::ClientDeadline;
pub use complete::CompletionOptions;
pub use complete::CompletionPlan;
pub use complete::DEFAULT_CLIENT_GRACE;
pub use complete::KillAnswer;
pub use complete::NO_TIMEOUT_CEILING;
pub use complete::OutputFlow;
pub use complete::OutputSink;
pub use exec::DEFAULT_EXEC_WAIT;
pub use exec::EndReason;
pub use exec::ExecHandle;
pub use exec::ExecResult;
pub use exec::StreamEnd;
pub use exec::StreamOptions;
pub use exec::TIMED_OUT_EXIT_CODE;
pub use exec::exec_id_at;
pub use http::ChunkSource;
pub use http::HttpBackend;
pub use http::HttpRequest;
pub use http::HttpResponse;
pub use http::OpenStream;
pub use http::SharedBackend;
pub use keepalive::KeepAwake;
pub use keepalive::KeepAwakeEnd;
pub use keepalive::KeepAwakeReport;
pub use keepalive::KeepAwakeTask;
pub use keepalive::RunningGate;
pub use proxy::Clock;
pub use proxy::DEFAULT_AGENT_PORT;
pub use proxy::DEFAULT_REFRESH_AFTER;
pub use proxy::MAX_TOKEN_LIFETIME;
pub use proxy::PROXY_AUTH_HEADER;
pub use proxy::PROXY_PORT_HEADER;
pub use proxy::ProxyAuth;
pub use proxy::ProxyToken;
pub use proxy::TokenMinter;
pub use proxy::WS_AUTH_SUBPROTOCOL_PREFIX;
pub use proxy::WS_PORT_SUBPROTOCOL_PREFIX;
pub use proxy::WS_SUBPROTOCOL;
pub use split::GapLog;
pub use split::GapPolicy;
pub use split::OutputGap;
pub use split::Split;
pub use split::SplitItem;
pub use sse::ExecEvent;
pub use sse::Frame;
pub use sse::SseParser;

Modules§

complete
Run one command to exactly one result: Session::run_to_completion.
exec
The handle a caller holds for one running exec.
files
File and tar transfer. Four routes, opaque bodies, one query type.
http
The HTTP seam: one request/response shape, two backends.
keepalive
Keeping a VM awake from outside while work runs inside it.
proxy
The endpoint proxy’s authentication: two headers, and a token minted inside the request path.
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.

Structs§

LaunchMetrics
Measurements observed by this client’s launch, in Unix seconds for timestamps. Absent timestamps mean that phase has not been observed by this client.
Session
The control API of one running MicroVM.
SessionBuilder
Builds a Session. See Session::builder.
Transport
The transport: a backend, the agent token, and the proxy auth every request needs.

Constants§

DEFAULT_BIND
Where a tunnel or port-forward listens by default: loopback, on a port the OS picks. Loopback keeps the VM’s credentials from being exposed to remote connections.
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_READY_TIMEOUTDeprecated
The old name of DEFAULT_BOOTSTRAP_TIMEOUT, kept for one release.
DEFAULT_REQUEST_TIMEOUT
How long one non-streaming request may take.