mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Trend.tMux as struct instead of pointer
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user