Skip to main content

Module admin

Module admin 

Source
Expand description

Admin socket — push-style daemon-lifecycle event broadcast.

Specified in docs/protocol-v1.md §“Admin endpoint”. On connect, the daemon writes a snapshot frame (current state). Every state transition pushes another frame. Read-only stream from daemon → client; client writes are ignored.

Wire shape:

{"id":"admin","type":"status","status":"loading_model","phase":"download",
 "downloaded_bytes":33554432,"total_bytes":5126304928,
 "source_url":"https://huggingface.co/..."}

Architecture:

  • StatusBroadcaster wraps a tokio::sync::watch (for the “current state” snapshot newcomers see) and a tokio::sync::broadcast (for the live event stream).
  • serve_admin_* accept loops per platform; each accepted connection spawns a writer task that (1) writes the watch’s current value as the snapshot, then (2) forwards every broadcast event after that. Slow clients overflow the broadcast buffer and get disconnected with EOF — they reconnect to resume.

Structs§

StatusBroadcaster
Daemon-wide status broadcaster.

Constants§

ADMIN_BROADCAST_CAPACITY
Capacity of the broadcast channel that fans events out to admin clients. Past this, slow clients lag behind and the daemon drops them — they reconnect to resume from the current snapshot.

Functions§

serve_admin_uds
Serve an admin Unix domain socket (Unix only). Loops until shutdown resolves.