Files
kubeshark/api/pkg/tap/stats_tracker.go
gadotroee 0d277faaf8 API and TAP in single process (#24)
* no message
* no message
2021-05-02 15:00:53 +03:00

36 lines
499 B
Go

package tap
import (
"sync"
)
type AppStats struct {
matchedMessages int
}
type StatsTracker struct {
stats AppStats
statsMutex sync.Mutex
}
func (st *StatsTracker) incMatchedMessages() {
st.statsMutex.Lock()
st.stats.matchedMessages++
st.statsMutex.Unlock()
}
func (st *StatsTracker) dumpStats() AppStats {
st.statsMutex.Lock()
stats := AppStats{
matchedMessages: st.stats.matchedMessages,
}
st.stats.matchedMessages = 0
st.statsMutex.Unlock()
return stats
}