1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-27 12:35:21 -05:00

move stats and inbound to features directory

This commit is contained in:
Darien Raymond
2018-10-11 21:14:53 +02:00
parent b6dc31d3fe
commit 273342d0b9
15 changed files with 161 additions and 138 deletions

26
features/stats/stats.go Normal file
View File

@@ -0,0 +1,26 @@
package stats
import "v2ray.com/core/features"
type Counter interface {
Value() int64
Set(int64) int64
Add(int64) int64
}
type Manager interface {
features.Feature
RegisterCounter(string) (Counter, error)
GetCounter(string) Counter
}
// GetOrRegisterCounter tries to get the StatCounter first. If not exist, it then tries to create a new counter.
func GetOrRegisterCounter(m Manager, name string) (Counter, error) {
counter := m.GetCounter(name)
if counter != nil {
return counter, nil
}
return m.RegisterCounter(name)
}