Expand description
Typed request/response protocol for the node-local cache daemon.
Deliberately not REST/format!()-built URLs: every message is a
serde-serializable Rust enum. The wire framing is a small
length-prefixed envelope ([len: u32 LE][body: JSON bytes]) over
whatever AsyncRead/AsyncWrite transport the caller supplies (a
UnixStream in production, an in-memory duplex pipe in tests) — the
same “transport-agnostic frame, JSON/CBOR body” shape sui-protocol
already established for the graph daemon, kept independent here so
this crate has zero dependency on that daemon’s graph-specific wire
types.
JSON (not bincode) was chosen for the body encoding: this crate adds
no new workspace dependency (serde_json is already pulled in by
every consumer of this protocol), the messages are small and
infrequent (one per cache lookup, not a hot inner loop), and JSON’s
self-describing shape makes sui-dockerfile-node-cache-daemon --version-style debugging trivial with nc/socat during
incident response.
Structs§
- Cached
Artifact - The cache payload: today, an image reference string — the same
shape
sui_cache::storage::StorageBackend::get_narinfoalready returns for a Dockerfile-graph node hit. Kept as its own typed struct (rather than a bareString) so a future phase can widen it (e.g. add asize_bytesorbuilt_at) without an incompatible wire break at the enum level.
Enums§
- Daemon
Request - A request from a client (the daemon-aware wrapper client, or any other same-node caller) to the node cache daemon.
- Daemon
Response - A response from the node cache daemon.
- Warm
Status - Outcome of a
Warmrequest — never blocks the caller on the network fetch; reports only what could be determined synchronously.
Constants§
- MAX_
MESSAGE_ BYTES - Maximum body length a single frame may declare. 8 MiB is generously
larger than any
CachedArtifactthis daemon stores (an image reference string), catching a desynchronized or hostile peer before it forces a runaway allocation.
Functions§
- read_
message - Read one length-prefixed JSON message from
r. - write_
message - Write one length-prefixed JSON message to
w.