diff --git a/agents/agentreq.go b/agents/agentreq.go index fa690732f..07da0387f 100644 --- a/agents/agentreq.go +++ b/agents/agentreq.go @@ -130,7 +130,7 @@ func (ar *AgentRequest) FieldAsInterface(fldPath []string) (val interface{}, err val, err = ar.Trailer.FieldAsInterface(fldPath[1:]) case utils.MetaTmp: val, err = ar.tmp.FieldAsInterface(fldPath[1:]) - case utils.MetaCache: + case utils.MetaUCH: if cacheVal, ok := engine.Cache.Get(utils.CacheUCH, strings.Join(fldPath[1:], utils.NestingSep)); !ok { err = utils.ErrNotFound } else { @@ -281,8 +281,8 @@ func (ar *AgentRequest) Set(fullPath *utils.FullPath, nm utils.NMInterface) (add PathItems: fullPath.PathItems[1:], Path: fullPath.Path[6:], }, nm) - case utils.MetaCache: - err = engine.Cache.Set(utils.CacheUCH, fullPath.Path[7:], nm, nil, true, utils.NonTransactional) + case utils.MetaUCH: + err = engine.Cache.Set(utils.CacheUCH, fullPath.Path[5:], nm, nil, true, utils.NonTransactional) } return false, err } @@ -304,7 +304,7 @@ func (ar *AgentRequest) RemoveAll(prefix string) error { ar.diamreq.RemoveAll() case utils.MetaTmp: ar.tmp = utils.NavigableMap2{} - case utils.MetaCache: + case utils.MetaUCH: engine.Cache.Clear([]string{utils.CacheUCH}) case utils.MetaOpts: ar.Opts.RemoveAll() @@ -343,8 +343,8 @@ func (ar *AgentRequest) Remove(fullPath *utils.FullPath) error { PathItems: fullPath.PathItems[1:].Clone(), Path: fullPath.Path[6:], }) - case utils.MetaCache: - return engine.Cache.Remove(utils.CacheUCH, fullPath.Path[7:], true, utils.NonTransactional) + case utils.MetaUCH: + return engine.Cache.Remove(utils.CacheUCH, fullPath.Path[5:], true, utils.NonTransactional) } } diff --git a/agents/agentreq_test.go b/agents/agentreq_test.go index b0c16c321..507030f2c 100644 --- a/agents/agentreq_test.go +++ b/agents/agentreq_test.go @@ -1812,10 +1812,10 @@ func TestAgReqSetFieldsInCache(t *testing.T) { tplFlds := []*config.FCTemplate{ {Tag: "Tenant", - Path: utils.MetaCache + utils.NestingSep + utils.Tenant, Type: utils.MetaVariable, + Path: utils.MetaUCH + utils.NestingSep + utils.Tenant, Type: utils.MetaVariable, Value: config.NewRSRParsersMustCompile("cgrates.org", true, utils.INFIELD_SEP)}, {Tag: "Account", - Path: utils.MetaCache + utils.NestingSep + utils.Account, Type: utils.MetaVariable, + Path: utils.MetaUCH + utils.NestingSep + utils.Account, Type: utils.MetaVariable, Value: config.NewRSRParsersMustCompile("~*cgreq.Account", true, utils.INFIELD_SEP)}, } for _, v := range tplFlds { @@ -1825,19 +1825,19 @@ func TestAgReqSetFieldsInCache(t *testing.T) { t.Error(err) } - if val, err := agReq.FieldAsInterface([]string{utils.MetaCache, utils.Tenant}); err != nil { + if val, err := agReq.FieldAsInterface([]string{utils.MetaUCH, utils.Tenant}); err != nil { t.Error(err) } else if val != "cgrates.org" { t.Errorf("expecting: %+v, \n received: %+v ", "cgrates.org", utils.ToJSON(val)) } - if val, err := agReq.FieldAsInterface([]string{utils.MetaCache, utils.Account}); err != nil { + if val, err := agReq.FieldAsInterface([]string{utils.MetaUCH, utils.Account}); err != nil { t.Error(err) } else if val != "1001" { t.Errorf("expecting: %+v, \n received: %+v ", "1001", utils.ToJSON(val)) } - if _, err := agReq.FieldAsInterface([]string{utils.MetaCache, "Unexist"}); err == nil || err != utils.ErrNotFound { + if _, err := agReq.FieldAsInterface([]string{utils.MetaUCH, "Unexist"}); err == nil || err != utils.ErrNotFound { t.Error(err) } } @@ -1855,10 +1855,10 @@ func TestAgReqSetFieldsInCacheWithTimeOut(t *testing.T) { tplFlds := []*config.FCTemplate{ {Tag: "Tenant", - Path: utils.MetaCache + utils.NestingSep + utils.Tenant, Type: utils.MetaVariable, + Path: utils.MetaUCH + utils.NestingSep + utils.Tenant, Type: utils.MetaVariable, Value: config.NewRSRParsersMustCompile("cgrates.org", true, utils.INFIELD_SEP)}, {Tag: "Account", - Path: utils.MetaCache + utils.NestingSep + utils.Account, Type: utils.MetaVariable, + Path: utils.MetaUCH + utils.NestingSep + utils.Account, Type: utils.MetaVariable, Value: config.NewRSRParsersMustCompile("~*cgreq.Account", true, utils.INFIELD_SEP)}, } for _, v := range tplFlds { @@ -1868,27 +1868,27 @@ func TestAgReqSetFieldsInCacheWithTimeOut(t *testing.T) { t.Error(err) } - if val, err := agReq.FieldAsInterface([]string{utils.MetaCache, utils.Tenant}); err != nil { + if val, err := agReq.FieldAsInterface([]string{utils.MetaUCH, utils.Tenant}); err != nil { t.Error(err) } else if val != "cgrates.org" { t.Errorf("expecting: %+v, \n received: %+v ", "cgrates.org", utils.ToJSON(val)) } - if val, err := agReq.FieldAsInterface([]string{utils.MetaCache, utils.Account}); err != nil { + if val, err := agReq.FieldAsInterface([]string{utils.MetaUCH, utils.Account}); err != nil { t.Error(err) } else if val != "1001" { t.Errorf("expecting: %+v, \n received: %+v ", "1001", utils.ToJSON(val)) } - if _, err := agReq.FieldAsInterface([]string{utils.MetaCache, "Unexist"}); err == nil || err != utils.ErrNotFound { + if _, err := agReq.FieldAsInterface([]string{utils.MetaUCH, "Unexist"}); err == nil || err != utils.ErrNotFound { t.Error(err) } // give enough time to Cache to remove ttl the *uch time.Sleep(2 * time.Second) - if _, err := agReq.FieldAsInterface([]string{utils.MetaCache, utils.Tenant}); err == nil || err != utils.ErrNotFound { + if _, err := agReq.FieldAsInterface([]string{utils.MetaUCH, utils.Tenant}); err == nil || err != utils.ErrNotFound { t.Error(err) } - if _, err := agReq.FieldAsInterface([]string{utils.MetaCache, utils.Account}); err == nil || err != utils.ErrNotFound { + if _, err := agReq.FieldAsInterface([]string{utils.MetaUCH, utils.Account}); err == nil || err != utils.ErrNotFound { t.Error(err) } } diff --git a/config/eescfg.go b/config/eescfg.go index 794aaefce..84b87333d 100644 --- a/config/eescfg.go +++ b/config/eescfg.go @@ -205,7 +205,7 @@ func (eeC *EventExporterCfg) loadFromJsonCfg(jsnEec *EventExporterJsonCfg, separ case utils.MetaTrl: eeC.trailerFields = append(eeC.trailerFields, field) } - if strings.HasPrefix(field.GetPathSlice()[0], utils.MetaCache) { // special cache when loading fields that contains *cache in path + if strings.HasPrefix(field.GetPathSlice()[0], utils.MetaUCH) { // special cache when loading fields that contains *uch in path eeC.contentFields = append(eeC.contentFields, field) } } diff --git a/data/conf/samples/ees/cgrates.json b/data/conf/samples/ees/cgrates.json index 8826234ae..fc160f213 100644 --- a/data/conf/samples/ees/cgrates.json +++ b/data/conf/samples/ees/cgrates.json @@ -305,11 +305,11 @@ "attempts": 1, "filters": ["*string:~*req.ExporterUsed:RouteExporter"], "fields":[ - {"tag": "Cost", "path": "*cache[~*req.CGRID|~*req.RunID|-Cost]", "type": "*variable", + {"tag": "Cost", "path": "*uch[~*req.CGRID|~*req.RunID|-Cost]", "type": "*variable", "value": "~*req.Cost", "rounding_decimals": 4}, - {"tag": "Account", "path": "*cache[~*req.CGRID|~*req.RunID|-Account]", "type": "*variable", "value": "~*req.Account"}, - {"tag": "RunID", "path": "*cache[~*req.CGRID|~*req.RunID|-RunID]", "type": "*variable", "value": "~*req.RunID"}, - {"tag": "CustomVariable", "path": "*cache[~*req.CGRID|~*req.RunID|-CustomVariable]", + {"tag": "Account", "path": "*uch[~*req.CGRID|~*req.RunID|-Account]", "type": "*variable", "value": "~*req.Account"}, + {"tag": "RunID", "path": "*uch[~*req.CGRID|~*req.RunID|-RunID]", "type": "*variable", "value": "~*req.RunID"}, + {"tag": "CustomVariable", "path": "*uch[~*req.CGRID|~*req.RunID|-CustomVariable]", "type": "*variable", "value": "CustomValue"} ], }, @@ -330,12 +330,12 @@ {"tag": "Tenant", "path": "*exp.Tenant", "type": "*variable", "value": "~*req.Tenant"}, {"tag": "Account", "path": "*exp.Account", "type": "*variable", "value": "~*req.Account"}, {"tag": "Cost", "path": "*exp.Cost", "type": "*variable", "value": "~*req.Cost", "rounding_decimals": 4}, - {"tag": "SupplierCustomVariable","filters": ["*exists:*cache[~*req.CGRID|~*req.RunID|-CustomVariable]:"], - "path": "*exp.SupplierCustomVariable", "type": "*variable", "value": "~*cache[~*req.CGRID|~*req.RunID|-CustomVariable]"}, - {"tag": "SupplierCost","filters": ["*exists:*cache[~*req.CGRID|~*req.RunID|-Cost]:"], - "path": "*exp.SupplierCost", "type": "*variable", "value": "~*cache[~*req.CGRID|~*req.RunID|-Cost]"}, - {"tag": "SupplierRun","filters": ["*exists:*cache[~*req.CGRID|~*req.RunID|-RunID]:"], - "path": "*exp.SupplierRun", "type": "*variable", "value": "~*cache[~*req.CGRID|~*req.RunID|-RunID]"}, + {"tag": "SupplierCustomVariable","filters": ["*exists:*uch[~*req.CGRID|~*req.RunID|-CustomVariable]:"], + "path": "*exp.SupplierCustomVariable", "type": "*variable", "value": "~*uch[~*req.CGRID|~*req.RunID|-CustomVariable]"}, + {"tag": "SupplierCost","filters": ["*exists:*uch[~*req.CGRID|~*req.RunID|-Cost]:"], + "path": "*exp.SupplierCost", "type": "*variable", "value": "~*uch[~*req.CGRID|~*req.RunID|-Cost]"}, + {"tag": "SupplierRun","filters": ["*exists:*uch[~*req.CGRID|~*req.RunID|-RunID]:"], + "path": "*exp.SupplierRun", "type": "*variable", "value": "~*uch[~*req.CGRID|~*req.RunID|-RunID]"}, ], } ] diff --git a/ees/eereq.go b/ees/eereq.go index 8c60f1ff0..4441fc363 100644 --- a/ees/eereq.go +++ b/ees/eereq.go @@ -81,7 +81,7 @@ func (eeR *EventExporterRequest) FieldAsInterface(fldPath []string) (val interfa return nil, fmt.Errorf("unsupported field prefix: <%s>", fldPath[0]) case utils.MetaReq: val, err = eeR.req.FieldAsInterface(fldPath[1:]) - case utils.MetaCache: + case utils.MetaUCH: if cacheVal, ok := engine.Cache.Get(utils.CacheUCH, strings.Join(fldPath[1:], utils.NestingSep)); !ok { err = utils.ErrNotFound } else { @@ -196,8 +196,8 @@ func (eeR *EventExporterRequest) Set(fullPath *utils.FullPath, nm utils.NMInterf PathItems: fullPath.PathItems[1:], Path: fullPath.Path[4:], }, nm) - case utils.MetaCache: - err = engine.Cache.Set(utils.CacheUCH, fullPath.Path[7:], nm, nil, true, utils.NonTransactional) + case utils.MetaUCH: + err = engine.Cache.Set(utils.CacheUCH, fullPath.Path[5:], nm, nil, true, utils.NonTransactional) } return false, err } diff --git a/engine/filters.go b/engine/filters.go index fd0b167d2..3ddf84cd1 100644 --- a/engine/filters.go +++ b/engine/filters.go @@ -549,7 +549,7 @@ func (dDP *dynamicDP) RemoteHost() net.Addr { var initialDPPrefixes = utils.NewStringSet([]string{utils.MetaReq, utils.MetaVars, utils.MetaCgreq, utils.MetaCgrep, utils.MetaRep, utils.MetaCGRAReq, - utils.MetaAct, utils.MetaEC, utils.MetaCache}) + utils.MetaAct, utils.MetaEC, utils.MetaUCH}) func (dDP *dynamicDP) FieldAsInterface(fldPath []string) (val interface{}, err error) { if len(fldPath) == 0 { diff --git a/packages/debian/changelog b/packages/debian/changelog index 682f044ea..a4c66800d 100644 --- a/packages/debian/changelog +++ b/packages/debian/changelog @@ -71,6 +71,7 @@ cgrates (0.11.0~dev) UNRELEASED; urgency=medium * [SessionS] Use correctly SessionTTLUsage when calculate end usage in case of terminate session from ttl mechanism * [SessionS] Add SessionTLLLastUsage as option for an extra debit in case of ttl mechanism * [LoaderS] Add *req as mandatory prefix + * [AgentS] Rename prefix from *cache to *uch -- DanB Wed, 19 Feb 2020 13:25:52 +0200 diff --git a/utils/consts.go b/utils/consts.go index f46688ecd..e446ccb75 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -373,7 +373,7 @@ const ( MetaCDRs = "*cdrs" MetaDC = "*dc" MetaCaches = "*caches" - MetaCache = "*cache" + MetaUCH = "*uch" MetaGuardian = "*guardians" MetaEEs = "*ees" MetaRateS = "*rates"