Skip to content

Add cmd/inspect: eventbus + LiveView demo#39

Merged
kaeawc merged 1 commit into
mainfrom
work/cmd-inspect
May 4, 2026
Merged

Add cmd/inspect: eventbus + LiveView demo#39
kaeawc merged 1 commit into
mainfrom
work/cmd-inspect

Conversation

@kaeawc

@kaeawc kaeawc commented May 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • New `cmd/inspect` binary wires `internal/eventbus` into `tui.LiveView`. The `Inspector` subscribes to an `eventbus.Async[Event]`, accumulates counters + a ring buffer of the most recent events, exposes itself as a `tui.LiveSampler`.
  • Three synthetic scenarios drive the bus: `steady` (10/s, info-only), `bursty` (50-event bursts every 2s), `noisy` (20/s mixed levels).
  • Picker → LiveView dashboard → Done. Global quit shuts down the producer + inspector + bus before `tea.Quit`.
  • Renderer is split into `renderHeader`/`renderLevelTable`/`renderKindTable`/`renderRecent` to keep the top-level fn under gocyclo.
  • Headless: `--scenario X --duration Y --yes` for CI / demo runs.

Test plan

  • Inspector accumulates totals, ring-buffers to capacity, returns copied maps from Snapshot
  • Stop() freezes Elapsed; Sample reports done after Stop
  • Scenario lookup matrix
  • runSteady + runNoisy actually publish events in a bounded window (race-safe poll loops)
  • Model end-to-end (pick → LiveView active → LiveDoneMsg → Done)
  • Global quit shuts down producer (verified bus is non-nil before, no panic on second cancel)
  • Headless: happy path produces summary; bad scenario / zero duration / missing scenario all reject
  • renderSnapshot mentions all key metrics
  • `go vet`, `gofmt`, `gocyclo`, `gosec`, `golangci-lint` clean
  • Smoke: `./inspect --scenario noisy --duration 500ms --yes` produces well-formed dashboard

cmd/inspect wires internal/eventbus into the tui.LiveView phase so a
real subscription drives a live dashboard:

- Inspector subscribes to an eventbus.Async[Event], accumulates total
  count, per-level/-kind counters, and a ring buffer of the most
  recent events; exposes Snapshot via tui.LiveSampler.
- Synthetic Scenario producers (steady, bursty, noisy) publish events
  in a goroutine until ctx cancellation.
- TUI: scenario picker → LiveView dashboard → Done on quit. Global
  quit shuts down producer + inspector + bus before tea.Quit.

Headless: --scenario X --duration Y --yes runs end-to-end without a
TTY and prints the final dashboard.

Renderer is split into renderHeader / renderLevelTable /
renderKindTable / renderRecent so the top-level renderSnapshot stays
under the gocyclo threshold.
@kaeawc kaeawc enabled auto-merge (squash) May 4, 2026 13:47
@kaeawc kaeawc merged commit 88f9e3d into main May 4, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant