Skip to main content

Module feed

Module feed 

Source
Expand description

The server-side half of the live feed: a FeedHub that watches every published blockfile event in-process (a broker observer, so no WebSocket route is involved) and hands each open feed the changes of the one file it follows: an agent’s transcript (output), or a terminal’s output (term, for the terminal feed in super::terminal); plus the pure pieces of the feed’s wire (cursor, frame truncation, SSE framing) the route assembles.

Nothing is buffered without bound for a slow device: a subscription counts the bytes queued for it, and once more than MAX_BEHIND_BYTES wait it stops queueing and receives one HubEvent::Behind, on which the feed sends reset and closes (the device reconnects and gets a snapshot).

Structs§

Cursor
Where a feed stands in its stream: the generation it is reading and the next line it has not sent.
FeedHub
Every open feed’s subscription, by the block and file it follows.
FeedSubscription
One feed’s subscription; unsubscribes when dropped.
Subscriber 🔒

Enums§

AppendStep
What to do with one published append.
HubEvent
What a subscription receives.

Constants§

MAX_BEHIND_BYTES
A stream more than this far behind is reset and closed.
MAX_FRAME_BYTES
A frame longer than this is replaced by an amx_truncated frame.
TERM_FILE
A terminal block’s output file: raw PTY bytes.
TRUNCATED_HEAD_CHARS
How much of a truncated frame is kept, in characters.

Functions§

apply_append
Apply one published append to cursor.
device_frame
A frame as the device gets it: as written, or, over MAX_FRAME_BYTES, an amx_truncated frame with its size and head.
device_frames
device_frame over a batch.
parse_event_id
Last-Event-ID read back: (gen, next line).
queued_size 🔒
What records of filename cost a subscriber: a transcript’s lines as the device gets them (wire_size); a terminal’s bytes as they are.
split_records
The lines in published records, split the way blockfile:read_range splits the file, so the counts agree.
sse_event
One SSE event. data is serde output on one line, so no raw newline can end the data: field early.
status_step
Whether a feed sends a status event now, given the state it last sent (shown, updated here) and the state now: Some(Some(_)) sends a state, Some(None) sends state: null so the device drops a chip it shows, None sends nothing. Right after a snapshot (after_snapshot) a known state is always sent; otherwise only a change of state or since_ms is. An agent that has never had a state gets no event at all.
wire_size
About how many bytes records cost on the wire: each line as the device gets it, so at most MAX_FRAME_BYTES however large it is written. One 5 MB tool result is 64 KB behind, not 5 MB.