From 140d6c0fe472f112170022b9831dfe700698f382 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 13 May 2026 14:25:22 +0300 Subject: 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 --- internal/event/event.go | 26 ++++++++++++++++++++++---- 1 file 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() } -- cgit v1.2.3