mirror of https://github.com/rocboss/paopao-ce
parent
0260f8290a
commit
5d637fe0d3
@ -0,0 +1,38 @@
|
||||
// Copyright 2023 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package statistics
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/rocboss/paopao-ce/internal/core"
|
||||
)
|
||||
|
||||
var (
|
||||
_metricCache core.MetricCache
|
||||
_onceMetricCache sync.Once
|
||||
)
|
||||
|
||||
type metricCache struct {
|
||||
eventTempWorkerCount map[string]int
|
||||
}
|
||||
|
||||
func (m *metricCache) SetEventTempWorkerCount(name string, count int) {
|
||||
// 直接赋值,不需要加锁,因为这仅仅是一个统计信息
|
||||
m.eventTempWorkerCount[name] = count
|
||||
}
|
||||
|
||||
func (m *metricCache) GetEventTempWorkerCount(name string) int {
|
||||
return m.eventTempWorkerCount[name]
|
||||
}
|
||||
|
||||
func NewMetricCache() core.MetricCache {
|
||||
_onceMetricCache.Do(func() {
|
||||
_metricCache = &metricCache{
|
||||
eventTempWorkerCount: make(map[string]int),
|
||||
}
|
||||
})
|
||||
return _metricCache
|
||||
}
|
Loading…
Reference in new issue