feat: add peerstat package with Sink interface and NoopSink

This commit is contained in:
Jay
2026-05-19 13:47:17 -04:00
parent 1a7dd561b5
commit ce0b13e914
2 changed files with 36 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
// Package peerstat defines the contract for collecting peer-level statistics.
package peerstat
// Sink is the interface through which add-ons report statistics.
// Add-ons should call Record() with a peer ID and a typed event when
// significant events occur. The event parameter is expected to be a
// domain-specific struct defined in the add-on's package.
type Sink interface {
// Record reports a statistic event for a given peer.
// The event parameter contains the domain-specific details.
Record(peerID string, event any)
}
// NoopSink is a null implementation of Sink that does nothing.
// It is used when no actual statistics collector is wired in.
type NoopSink struct{}
// Record implements Sink for NoopSink, doing nothing.
func (NoopSink) Record(_ string, _ any) {}