// Package stats tracks runtime statistics since server boot. package stats import ( "sync/atomic" ) // Tracker holds atomic counters for runtime statistics // that accumulate since the server started. type Tracker struct { connectionsSinceBoot atomic.Int64 sessionsSinceBoot atomic.Int64 messagesSinceBoot atomic.Int64 } // New creates a new Tracker with all counters at zero. func New() *Tracker { return &Tracker{} //nolint:exhaustruct // atomic fields have zero-value defaults } // IncrConnections increments the total connection count. func (t *Tracker) IncrConnections() { t.connectionsSinceBoot.Add(1) } // IncrSessions increments the total session count. func (t *Tracker) IncrSessions() { t.sessionsSinceBoot.Add(1) } // IncrMessages increments the total PRIVMSG/NOTICE count. func (t *Tracker) IncrMessages() { t.messagesSinceBoot.Add(1) } // ConnectionsSinceBoot returns the total number of // client connections since boot. func (t *Tracker) ConnectionsSinceBoot() int64 { return t.connectionsSinceBoot.Load() } // SessionsSinceBoot returns the total number of sessions // created since boot. func (t *Tracker) SessionsSinceBoot() int64 { return t.sessionsSinceBoot.Load() } // MessagesSinceBoot returns the total number of // PRIVMSG/NOTICE messages sent since boot. func (t *Tracker) MessagesSinceBoot() int64 { return t.messagesSinceBoot.Load() }