TrendS with separate variable for Mutex, to keep vet happy

This commit is contained in:
DanB
2024-09-16 21:14:46 +02:00
parent 6e84b555be
commit 347fe7f6ed
3 changed files with 6 additions and 5 deletions

View File

@@ -92,7 +92,7 @@ type TrendWithAPIOpts struct {
// Trend is the unit matched by filters
type Trend struct {
*sync.RWMutex
tMux *sync.RWMutex
Tenant string
ID string

View File

@@ -32,7 +32,7 @@ func TestTrendGetTrendGrowth(t *testing.T) {
t2 := now.Add(-2 * time.Second)
t3 := now.Add(-3 * time.Second)
trnd1 := &Trend{
RWMutex: &sync.RWMutex{},
tMux: new(sync.RWMutex),
Tenant: "cgrates.org",
ID: "TestTrendGetTrendLabel",
RunTimes: []time.Time{t3, t2, t1},
@@ -59,7 +59,8 @@ func TestTrendGetTrendLabel(t *testing.T) {
t2 := now.Add(-2 * time.Second)
t3 := now.Add(-3 * time.Second)
trnd1 := &Trend{
RWMutex: sync.RWMutex{},
tMux: new(sync.RWMutex),
Tenant: "cgrates.org",
ID: "TestTrendGetTrendLabel",
RunTimes: []time.Time{t3, t2, t1},

View File

@@ -91,8 +91,8 @@ func (tS *TrendS) computeTrend(tP *TrendProfile) {
return
}
trend.Lock()
defer trend.Unlock()
trend.tMux.Lock()
defer trend.tMux.Unlock()
now := time.Now()
var metrics []string