mirror of
https://github.com/openziti/zrok.git
synced 2024-11-29 03:24:15 +01:00
27 lines
563 B
Go
27 lines
563 B
Go
package model
|
|
|
|
type Metrics struct {
|
|
Now int64 `json:"now"`
|
|
Sessions map[string]SessionMetrics
|
|
}
|
|
|
|
func (m *Metrics) PushSession(svcName string, sm SessionMetrics) {
|
|
if m.Sessions == nil {
|
|
m.Sessions = make(map[string]SessionMetrics)
|
|
}
|
|
if prev, found := m.Sessions[svcName]; found {
|
|
prev.BytesRead += sm.BytesRead
|
|
prev.BytesWritten += sm.BytesWritten
|
|
prev.LastUpdate = sm.LastUpdate
|
|
m.Sessions[svcName] = prev
|
|
} else {
|
|
m.Sessions[svcName] = sm
|
|
}
|
|
}
|
|
|
|
type SessionMetrics struct {
|
|
BytesRead int64
|
|
BytesWritten int64
|
|
LastUpdate int64
|
|
}
|