Trend.tMux as struct instead of pointer

This commit is contained in:
DanB
2024-10-02 13:06:46 +02:00
parent f0598b050b
commit 149ccc3eac
3 changed files with 1 additions and 9 deletions

View File

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

View File

@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package engine
import (
"sync"
"testing"
"time"
@@ -32,7 +31,6 @@ func TestTrendGetTrendGrowth(t *testing.T) {
t2 := now.Add(-2 * time.Second)
t3 := now.Add(-3 * time.Second)
trnd1 := &Trend{
tMux: new(sync.RWMutex),
Tenant: "cgrates.org",
ID: "TestTrendGetTrendLabel",
RunTimes: []time.Time{t3, t2, t1},
@@ -59,8 +57,6 @@ func TestTrendGetTrendLabel(t *testing.T) {
t2 := now.Add(-2 * time.Second)
t3 := now.Add(-3 * time.Second)
trnd1 := &Trend{
tMux: new(sync.RWMutex),
Tenant: "cgrates.org",
ID: "TestTrendGetTrendLabel",
RunTimes: []time.Time{t3, t2, t1},

View File

@@ -83,7 +83,6 @@ func (tS *TrendS) computeTrend(tP *TrendProfile) {
ID: tP.ID,
RunTimes: make([]time.Time, 0),
Metrics: make(map[time.Time]map[string]*MetricWithTrend),
tMux: new(sync.RWMutex),
}
} else if err != nil {
utils.Logger.Warning(
@@ -92,9 +91,6 @@ func (tS *TrendS) computeTrend(tP *TrendProfile) {
utils.TrendS, tP.Tenant, tP.ID, err.Error()))
return
}
if trend.tMux == nil {
trend.tMux = new(sync.RWMutex)
}
trend.tMux.Lock()
defer trend.tMux.Unlock()
trend.cleanup(tP.TTL, tP.QueueLength)