Skip to main content

Module lifecycle

Module lifecycle 

Source
Expand description

Daemon lifecycle: boot → wait-for-ready → bind listener → accept → dispatch → shutdown.

The M1 lifecycle wires:

  • lock — single-instance lock at startup (THREAT_MODEL F-2).
  • router — backend selection (no-op v0.1 — picks the only one).
  • endpoint — listener bound only after router.all_ready() (THREAT_MODEL F-13).
  • queue — admission gate (SubmitError::QueueFull → wire code: queue_full).
  • inferd-proto — frame parsing and serialisation.

Cancellation: dropping a connection drops the in-flight TokenStream, which closes the engine’s tx and stops the spawned generation task. Per ADR 0007 the daemon emits no terminal frame on cancel — the EOF is the signal.

Structs§

AcceptContext
Per-accept context that the lifecycle hands to every spawned connection task.
ReadyTimeout
Returned when wait_for_ready exhausts its budget without seeing readiness across every backend.

Functions§

handle_connection
Handle one accepted client connection: read framed Requests and write framed Responses until EOF or fatal error.
serve_tcp
Serve a TCP listener: accept loop, spawn one task per connection.
serve_uds
Serve a Unix domain socket listener (Unix only).
wait_for_ready
Wait until every backend in router reports ready, polling at 50ms intervals up to timeout. Returns the duration spent waiting.