mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated threshold processing for resources
This commit is contained in:
committed by
Dan Christian Bogos
parent
962a6c4397
commit
ccbccb8ff7
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user