Updated threshold processing for resources

This commit is contained in:
Trial97
2021-05-20 17:15:54 +03:00
committed by Dan Christian Bogos
parent 962a6c4397
commit ccbccb8ff7
2 changed files with 19 additions and 19 deletions

View File

@@ -983,13 +983,14 @@ func testV1RsRemResourceProfileWithoutTenant(t *testing.T) {
func testV1RsSetResourceProfileWithOpts(t *testing.T) {
rlsCfg := &engine.ResourceProfileWithAPIOpts{
ResourceProfile: &engine.ResourceProfile{
Tenant: "cgrates.org",
ID: "TEST_WITH_OPTS",
FilterIDs: []string{"*string:~*opts.CustomField:1007"},
UsageTTL: time.Duration(1) * time.Nanosecond,
Limit: 10,
Blocker: true,
Weight: 20,
Tenant: "cgrates.org",
ID: "TEST_WITH_OPTS",
FilterIDs: []string{"*string:~*opts.CustomField:1007"},
UsageTTL: time.Duration(1) * time.Nanosecond,
Limit: 10,
Blocker: true,
Weight: 20,
ThresholdIDs: []string{utils.MetaNone},
},
}
var reply string

View File

@@ -705,19 +705,18 @@ func (rS *ResourceService) V1AllocateResources(args utils.ArgRSv1ResourceUsage,
// index it for storing
for _, r := range mtcRLs {
if rS.cgrcfg.ResourceSCfg().StoreInterval == 0 || r.dirty == nil {
continue
}
if rS.cgrcfg.ResourceSCfg().StoreInterval == -1 {
*r.dirty = true
if err = rS.StoreResource(r); err != nil {
return
if rS.cgrcfg.ResourceSCfg().StoreInterval != 0 && r.dirty != nil {
if rS.cgrcfg.ResourceSCfg().StoreInterval == -1 {
*r.dirty = true
if err = rS.StoreResource(r); err != nil {
return
}
} else {
*r.dirty = true // mark it to be saved
rS.srMux.Lock()
rS.storedResources.Add(r.TenantID())
rS.srMux.Unlock()
}
} else {
*r.dirty = true // mark it to be saved
rS.srMux.Lock()
rS.storedResources.Add(r.TenantID())
rS.srMux.Unlock()
}
if err = rS.processThresholds(r, args.APIOpts); err != nil {
return