diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-12 23:16:46 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-12 23:16:46 +0300 |
| commit | 119c679dd16d6a3c89b9d37665c44815956b6f82 (patch) | |
| tree | cdff21d863f689b7fb0b350d448021fd3a2481be /internal/runtime | |
| parent | 0a342e08ebcc475524582260ab05841adf111596 (diff) | |
add compile-time interface satisfaction assertions for public types
Add var _ Interface = (*ConcreteType)(nil) assertions for:
- *flamegraph.LiveTrie → runtime.{Snapshotter,Configurator,LiveTrieSource}
and tui/flamegraph.{Snapshotter,Configurator,LiveTrieSource}
- *probemanager.Manager → runtime.ProbeManager
- *statsengine.Engine → runtime.SnapshotSource
- *streamrow.RingBuffer → runtime.EventSink
- *runtimeBindings (tui) → runtime.TraceRuntimeBindings
- *lateBoundDashboardSource → dashboard.SnapshotSource
- libbpfTracepointProgram/Module → probemanager.{Program,Attacher}
Assertions are grouped close to their interface definitions to avoid
introducing new import cycles (runtime already imports all affected
packages; tui/flamegraph already imports coreflamegraph).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/runtime')
| -rw-r--r-- | internal/runtime/runtime.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/runtime/runtime.go b/internal/runtime/runtime.go index 5e6f2a4..307c012 100644 --- a/internal/runtime/runtime.go +++ b/internal/runtime/runtime.go @@ -186,3 +186,31 @@ func TraceFiltersFromContext(ctx context.Context) (globalfilter.Filter, bool) { } return filters.filter.Clone(), true } + +// --- compile-time interface satisfaction assertions --- +// +// These blank-identifier assignments cause a build error if any concrete type +// drifts out of sync with the interface it claims to satisfy. They are grouped +// here because the runtime package already imports every relevant package +// (*flamegraph.LiveTrie, *probemanager.Manager, *statsengine.Engine, and +// *streamrow.RingBuffer), keeping the assertions co-located with the interface +// definitions without introducing new import cycles. + +var ( + // *flamegraph.LiveTrie must satisfy both the read-only and mutating sides of + // the trie contract as well as the combined LiveTrieSource interface. + _ Snapshotter = (*flamegraph.LiveTrie)(nil) + _ Configurator = (*flamegraph.LiveTrie)(nil) + _ LiveTrieSource = (*flamegraph.LiveTrie)(nil) + + // *probemanager.Manager must satisfy the probe-control surface exposed to the TUI. + _ ProbeManager = (*probemanager.Manager)(nil) + + // *statsengine.Engine must satisfy the snapshot-source contract used by the + // dashboard and the TUI runtime. + _ SnapshotSource = (*statsengine.Engine)(nil) + + // *streamrow.RingBuffer must satisfy the full event-sink contract (read + + // write sides), which is a superset of StreamSource. + _ EventSink = (*streamrow.RingBuffer)(nil) +) |
