Documentation
¶
Overview ¶
Package live provides a bounded, multi-region live console for streaming several concurrent outputs as fixed-height tiles.
Console stacks each Region as a bounded tile in a live area that is redrawn in place. The tiles are an ephemeral peek: each region retains only its most recent lines (a documented per-region bound), and the number of regions is capped (a documented backpressure bound), so a flood of transient progress never grows without limit. Durable signal — a region's final verdict — is written to scrollback above the live area on Console.Finish.
Rendering is deterministic and clock-free: the console redraws only when the caller calls Console.Render, writing to an injected io.Writer, so it is fully testable without a real terminal. Redrawing emits ANSI cursor-movement and clear sequences, so bind it to a terminal writer — a non-TTY sink (log or pipe) receives raw escape codes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// MaxRegions caps the number of concurrent regions;
// [Console.AddRegion] rejects further regions once reached (documented backpressure).
MaxRegions int
// RegionHeight caps the recent lines each region retains in the live view;
// older lines scroll out of the ephemeral peek (documented per-region bound).
RegionHeight int
}
Config bounds a Console's live area. The zero value is completed by NewConsole with the package defaults.
type Console ¶
type Console struct {
// contains filtered or unexported fields
}
Console is a bounded multi-region live console over an injected writer.
It is safe for concurrent use: regions may be appended to from separate goroutines while the owner periodically calls Console.Render. Ownership, cancellation, and render cadence belong to the caller — the console itself spawns no goroutines.
func NewConsole ¶
NewConsole creates a live console writing to w, bounded by config. The theme.Style carries the palette and glyph set that select the verdict symbols, so Console.Finish stays byte-clean on non-UTF-8 terminals.
func (*Console) AddRegion ¶
AddRegion appends a new tile titled title.
It returns an error once the configured Config.MaxRegions bound is reached, so callers apply backpressure rather than growing the live area without limit.
type Region ¶
type Region struct {
// contains filtered or unexported fields
}
Region is a single bounded tile within a Console.
It retains only its most recent lines (up to the console's configured height); older lines scroll out of the live peek. A region is safe to append to from a goroutine separate from the one rendering the console.
func (*Region) Done ¶
Done marks the region complete with a short summary shown on Console.Finish.
func (*Region) Fail ¶
Fail marks the region failed with a reason shown on Console.Finish.