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.
- Feed
Subscription - One feed’s subscription; unsubscribes when dropped.
- Subscriber 🔒
Enums§
- Append
Step - 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_truncatedframe. - 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, anamx_truncatedframe with its size and head. - device_
frames device_frameover a batch.- parse_
event_ id Last-Event-IDread back:(gen, next line).- queued_
size 🔒 - What
recordsoffilenamecost 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 wayblockfile:read_rangesplits the file, so the counts agree. - sse_
event - One SSE event.
datais serde output on one line, so no raw newline can end thedata:field early. - status_
step - Whether a feed sends a
statusevent now, given the state it last sent (shown, updated here) and the state now:Some(Some(_))sends a state,Some(None)sendsstate: nullso the device drops a chip it shows,Nonesends nothing. Right after a snapshot (after_snapshot) a known state is always sent; otherwise only a change of state orsince_msis. An agent that has never had a state gets no event at all. - wire_
size - About how many bytes
recordscost on the wire: each line as the device gets it, so at mostMAX_FRAME_BYTEShowever large it is written. One 5 MB tool result is 64 KB behind, not 5 MB.