mirror of
https://github.com/sot-tech/mochi.git
synced 2026-06-13 00:03:32 -07:00
global stats
This commit is contained in:
@@ -39,6 +39,14 @@ const (
|
||||
ErroredRequest
|
||||
)
|
||||
|
||||
// DefaultStats is a default instance of stats tracking that uses an unbuffered
|
||||
// channel for broadcasting events.
|
||||
var DefaultStats *Stats
|
||||
|
||||
func init() {
|
||||
DefaultStats = New(0)
|
||||
}
|
||||
|
||||
type PeerStats struct {
|
||||
// Stats for all peers.
|
||||
Completed uint64
|
||||
@@ -161,3 +169,8 @@ func (s *Stats) handleEvents() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RecordEvent broadcasts an event to the default stats tracking.
|
||||
func RecordEvent(event int) {
|
||||
DefaultStats.RecordEvent(event)
|
||||
}
|
||||
Reference in New Issue
Block a user