Documentation
¶
Index ¶
- func BuildInterfaceStats(name, link string, rx, tx int64) []*common.Stat
- type Entry
- type InterfaceCountersTracker
- type Sample
- type Tracker
- func (st *Tracker) AnyActiveSince(keys []string, cutoff time.Time) bool
- func (st *Tracker) CleanupDeletedEntries()
- func (st *Tracker) ClearAllStats()
- func (st *Tracker) EndpointActivity(keys []string) map[string]int64
- func (st *Tracker) GetStats(_ context.Context, keys []string, reset bool) *common.StatResponse
- func (st *Tracker) GetStatsEntries(keys []string) map[string]*Entry
- func (st *Tracker) GetUsersStats(_ context.Context, reset bool) *common.StatResponse
- func (st *Tracker) RemoveStats(publicKey string)
- func (st *Tracker) UpdateStatsBatch(samples []Sample)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Entry ¶
type Entry struct {
Email string
CurrentRx int64
CurrentTx int64
BaseRx int64
BaseTx int64
LastDeltaRx int64
LastDeltaTx int64
LastActiveTime time.Time
EndpointIP string
IsDeleted bool
}
Entry tracks stats for one user (map key = public key)
type InterfaceCountersTracker ¶
type InterfaceCountersTracker struct {
// contains filtered or unexported fields
}
InterfaceCountersTracker tracks delta and reset state for interface-level RX/TX counters.
func NewInterfaceCountersTracker ¶
func NewInterfaceCountersTracker() *InterfaceCountersTracker
func (*InterfaceCountersTracker) Delta ¶
func (t *InterfaceCountersTracker) Delta(currentRx, currentTx int64, reset bool) (int64, int64)
Delta calculates counters relative to the current baseline. On first sample, it sets baseline and returns zero. If counters roll back (interface reset/restart), it rebases and returns zero.
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker manages stats
func (*Tracker) AnyActiveSince ¶
AnyActiveSince reports whether any key has activity after the provided cutoff.
func (*Tracker) CleanupDeletedEntries ¶
func (st *Tracker) CleanupDeletedEntries()
CleanupDeletedEntries removes deleted peers once their remaining delta is fully accounted.
func (*Tracker) EndpointActivity ¶
EndpointActivity returns endpoint IP -> last seen unix timestamp for provided keys. If multiple keys share endpoint IP, the newest timestamp wins.
func (*Tracker) GetStatsEntries ¶
GetStatsEntries returns stats entries for specific public keys
func (*Tracker) GetUsersStats ¶
GetUsersStats returns stats for all public keys (all users)
func (*Tracker) RemoveStats ¶
RemoveStats marks a peer as deleted but keeps counters until a reset reports them.
func (*Tracker) UpdateStatsBatch ¶
UpdateStatsBatch applies many peer stats updates under a single lock.