Expand description
Streaming a running dataflow’s output to a terminal (blueprint §17:
astrs run “streams logs to the terminal”; astrs logs -f does the
same over the coordinator link).
embedded daemon ──DaemonEvent──► TerminalLogSink ──bounded──► printer task
(event loop) (never blocks, (owns stdout)
counts drops)
coordinator ──LogFrame──────────────────────────────────────► same printer§The sink must never block the event loop
astrs_daemon::health::ReportSink::report is called from inside the
daemon’s merged event loop, and its contract says so: “reporting must
never block the event loop and must never fail it”. A sink that took a
lock around a write! to a terminal would stall every node on the
machine behind a slow pipe. TerminalLogSink therefore does the one
thing that cannot stall: a try_send into a bounded channel, with a
counter for what did not fit. A separate task owns the sink and does the
formatting and the writing.
Bounded rather than unbounded on purpose: an unbounded channel in front of a terminal that has stopped being read is an out-of-memory bug with extra steps. Dropping the oldest news under sustained overload — and saying how much was dropped when the stream ends — is the behavior a log tail should have.
Structs§
- LogFilter
- Which items reach the terminal.
- LogStyle
- How the terminal is painted.
- Terminal
LogSink - The
ReportSinkastrs runinstalls on its embedded daemon.
Enums§
- Stream
Item - One thing worth printing.
Constants§
- STREAM_
CAPACITY - How many items may be queued between the daemon’s event loop and the printer before the oldest news starts being dropped.
Functions§
- level_
at_ least - Whether
levelis at least as severe asfloor. - parse_
level - Parses a
--levelargument, accepting the spellings a user types. - prefix_
width - The widest node name in a manifest, so the
[node]column is sized before the first line is printed rather than jittering as nodes appear. - print_
stream - Drains
receiverontooutuntil the stream ends, returning how many items were printed. - render
- Formats one item as the line a terminal shows.