live

package
v0.3.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 6 Imported by: 0

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

func NewConsole(w io.Writer, config Config, style theme.Style) *Console

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

func (c *Console) AddRegion(title string) (*Region, error)

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.

func (*Console) Finish

func (c *Console) Finish() error

Finish clears the live area and writes each region's durable verdict to scrollback, so the terminal retains signal rather than transient progress.

func (*Console) Render

func (c *Console) Render() error

Render redraws the whole live area in place: it moves the cursor up over the previous frame, clears it, and writes the current tiles.

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

func (r *Region) Done(summary string)

Done marks the region complete with a short summary shown on Console.Finish.

func (*Region) Fail

func (r *Region) Fail(reason string)

Fail marks the region failed with a reason shown on Console.Finish.

func (*Region) Println

func (r *Region) Println(line string)

Println appends a line to the region, dropping the oldest retained line once the height bound is exceeded (the ephemeral-peek bound).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL