github.com/Azareal/Gosora@v0.0.0-20210729070923-553e66b59003/common/counters/common.go (about) 1 package counters 2 3 import "sync" 4 5 // TODO: Make a neater API for this 6 var routeMapEnum map[string]int 7 var reverseRouteMapEnum map[int]string 8 9 func SetRouteMapEnum(rme map[string]int) { 10 routeMapEnum = rme 11 } 12 13 func SetReverseRouteMapEnum(rrme map[int]string) { 14 reverseRouteMapEnum = rrme 15 } 16 17 var agentMapEnum map[string]int 18 var reverseAgentMapEnum map[int]string 19 20 func SetAgentMapEnum(ame map[string]int) { 21 agentMapEnum = ame 22 } 23 24 func SetReverseAgentMapEnum(rame map[int]string) { 25 reverseAgentMapEnum = rame 26 } 27 28 var osMapEnum map[string]int 29 var reverseOSMapEnum map[int]string 30 31 func SetOSMapEnum(osme map[string]int) { 32 osMapEnum = osme 33 } 34 35 func SetReverseOSMapEnum(rosme map[int]string) { 36 reverseOSMapEnum = rosme 37 } 38 39 type RWMutexCounterBucket struct { 40 counter int 41 sync.RWMutex 42 } 43 44 type MutexCounterBucket struct { 45 counter int 46 sync.Mutex 47 } 48 49 type MutexCounter64Bucket struct { 50 counter int64 51 sync.Mutex 52 }