summaryrefslogtreecommitdiff
path: root/internal/runtime
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-13 14:41:28 +0300
committerPaul Buetow <paul@buetow.org>2026-05-13 14:41:28 +0300
commitde3405c275898c8cd528a636dbd40e1b685cfaa5 (patch)
tree53711959800677aa694e18331476add24a21b8ef /internal/runtime
parentd392eebe5bd127e1573734321b0cabaad4182d7c (diff)
use errgroup instead of WaitGroup for concurrent snapshot builders
Replace sync.WaitGroup with errgroup.Group in buildSubSnapshots so errors from sub-builders (buildSyscallSnapshots, buildFileSnapshots, buildProcessSnapshots, buildHistogramSnapshot) are captured and propagated rather than silently dropped. Change Engine.Snapshot() to return (*Snapshot, error), update runtime.SnapshotSource and dashboard.SnapshotSource interfaces accordingly, and adjust all callers in tui.go, dashboard/model.go, and the test helpers. Each sub-builder now returns (result, error); the error return is currently always nil but establishes the contract for future validation. The per-type Snapshot() convenience methods (histogram, syscall, file, process) panic on error since they are internal helpers where failure would be a programming bug. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/runtime')
-rw-r--r--internal/runtime/runtime.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/internal/runtime/runtime.go b/internal/runtime/runtime.go
index d6500d4..e8e278e 100644
--- a/internal/runtime/runtime.go
+++ b/internal/runtime/runtime.go
@@ -38,8 +38,10 @@ type EventSink interface {
// SnapshotSource provides statsengine snapshots for the TUI dashboard.
// The core tracing engine passes a *statsengine.Engine; the TUI stores it
// behind this interface so the dashboard can retrieve live snapshots.
+// Snapshot returns (nil, nil) when the engine is nil. A non-nil error
+// indicates that snapshot construction failed and the result must be discarded.
type SnapshotSource interface {
- Snapshot() *statsengine.Snapshot
+ Snapshot() (*statsengine.Snapshot, error)
}
// Snapshotter is the read-only subset of the trie contract used by consumers