cli-tui only.Expand description
Live terminal UI for faucet run --tui (#203, cli-tui feature).
The pipeline is untouched: it emits the same metrics series it always
does, and the TUI samples the in-process Prometheus recorder’s rendered
text a few times per second (read-only — zero hot-path impact) and draws
a full-screen ratatui view: per-invocation throughput, errors, DLQ
counts, bookmark age, and a live log pane. q (or Ctrl-C, which raw
mode delivers as a key event) cancels cooperatively via the executor’s
CancellationToken — in-flight invocations stop at their next page
boundary and flush their sinks.
Log handling: the normal stdout subscriber would corrupt the alternate
screen, so when a TUI session is detected at startup (--tui on a real
TTY), run_main routes the fmt subscriber into an in-memory ring
(log_buffer) that the TUI renders as its log pane. Lines are redacted
at capture with the same registry the stdout writer uses. On a non-TTY
(CI, pipes) the flag degrades to a plain run with a one-line notice.
Re-exports§
pub use crate::livemetrics as metrics;pub use crate::livemetrics::install_metrics_recorder;pub use crate::livemetrics::setup_observability;
Modules§
- view
- Rendering for the live TUI. The ratatui draw call is thin; everything that decides what to show (formatting, column selection under narrow widths, status labels) is a pure function with unit tests.
Structs§
- LogBuffer
- Ring-buffered log lines shared between the tracing subscriber (writer
side, installed in
run_main) and the TUI (render side). - LogBuffer
Writer - Line-splitting
io::Writeadapter for the tracing subscriber.
Traits§
- Cancel
Events - Source of user cancel requests — abstracted from crossterm so
drive_loopis testable against a scripted sequence.
Functions§
- drive
- Drive the run future under the full-screen TUI. Returns the run’s result
after the terminal is restored.
cancelis the token wired intoExecuteOptions.cancel;q/Ctrl-Ctrigger it. - drive_
loop - The render/cancel loop behind
drive, generic over the terminal backend and the event source so it runs headless under test. - flush_
logs_ to_ stderr - Flush the tail of the buffered log ring to stderr — called after terminal restore when the run failed, so the operator keeps the context that was on screen.
- install_
tui_ tracing - Install the ring-buffered tracing subscriber for a TUI session. Called by
run_maininstead of the stdout subscriber, before any log line is emitted. Returns the buffer for the render loop. - is_
tui_ session --tuiwas passed and stdout is a real terminal — the full-screen UI applies. On a non-TTY the caller degrades to a plain run.- log_
buffer - The TUI log ring, if
run_maininstalled one this process.