summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-13 14:25:22 +0300
committerPaul Buetow <paul@buetow.org>2026-05-13 14:25:22 +0300
commit140d6c0fe472f112170022b9831dfe700698f382 (patch)
tree6578380b05eb294019a45055a27ca58d668ae053
parent94aa1d0af0fa4d6c7873a4b5de0f55dfcc0aa03c (diff)
split Event interface into EventIdentity and EventLifecycle
Extract GetTraceId/GetPid/GetTid into EventIdentity (routing and aggregation concerns) and Recycle into EventLifecycle (pool memory management). Event embeds both and retains String, GetTime, Equals. All existing implementations satisfy the composed interface unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--internal/event/event.go26
1 files changed, 22 insertions, 4 deletions
diff --git a/internal/event/event.go b/internal/event/event.go
index c846e04..5fdd481 100644
--- a/internal/event/event.go
+++ b/internal/event/event.go
@@ -10,13 +10,31 @@ var poolOfEventPairs = sync.Pool{
New: func() any { return &Pair{} },
}
-// Event is the common contract implemented by decoded syscall trace events.
-type Event interface {
- String() string
+// EventIdentity carries the immutable identifiers of a decoded syscall event:
+// which syscall tracepoint fired (TraceId) and the kernel process/thread IDs
+// (Pid, Tid). It is embedded by Event and can be used independently wherever
+// only identity fields are needed (e.g. routing, filtering, aggregation keys).
+type EventIdentity interface {
GetTraceId() types.TraceId
GetPid() uint32
GetTid() uint32
+}
+
+// EventLifecycle manages the pool-backed memory lifetime of a decoded event.
+// Callers must call Recycle exactly once after the event is no longer needed
+// to return the underlying object to its sync.Pool. It is embedded by Event
+// and can be used independently wherever only lifecycle management is needed.
+type EventLifecycle interface {
+ Recycle()
+}
+
+// Event is the common contract implemented by decoded syscall trace events.
+// It composes EventIdentity (tracepoint + pid/tid) and EventLifecycle (pool
+// return) and adds timing, human-readable formatting, and equality comparison.
+type Event interface {
+ EventIdentity
+ EventLifecycle
+ String() string
GetTime() uint64
Equals(other any) bool
- Recycle()
}