From ff8a7f23f05c750dc02a20d0da6c6edcbefa58c0 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 9 Jan 2020 14:46:07 +0200 Subject: [PATCH] Added nested_fields config --- config/attributescfg.go | 4 ++++ config/chargerscfg.go | 4 ++++ config/config_defaults.go | 7 +++++++ config/config_json_test.go | 15 +++++++++++---- config/dispatchercfg.go | 4 ++++ config/libconfig_json.go | 7 +++++++ config/resourcescfg.go | 4 ++++ config/statscfg.go | 4 ++++ config/supplierscfg.go | 4 ++++ config/thresholdscfg.go | 4 ++++ data/conf/cgrates/cgrates.json | 14 +++++++++++++- dispatchers/dispatchers.go | 12 ++++++++---- engine/attributes.go | 18 +++++++++++++----- engine/chargers.go | 8 ++++++-- engine/filterhelpers.go | 2 +- engine/filterhelpers_test.go | 4 ++-- engine/resources.go | 9 +++++++-- engine/resources_test.go | 2 +- engine/stats.go | 9 +++++++-- engine/stats_test.go | 2 +- engine/suppliers.go | 9 +++++++-- engine/suppliers_test.go | 2 +- engine/thresholds.go | 10 +++++++--- 23 files changed, 127 insertions(+), 31 deletions(-) diff --git a/config/attributescfg.go b/config/attributescfg.go index 6b2b261a6..f19c76983 100644 --- a/config/attributescfg.go +++ b/config/attributescfg.go @@ -25,6 +25,7 @@ type AttributeSCfg struct { StringIndexedFields *[]string PrefixIndexedFields *[]string ProcessRuns int + NestedFields bool } func (alS *AttributeSCfg) loadFromJsonCfg(jsnCfg *AttributeSJsonCfg) (err error) { @@ -54,5 +55,8 @@ func (alS *AttributeSCfg) loadFromJsonCfg(jsnCfg *AttributeSJsonCfg) (err error) if jsnCfg.Process_runs != nil { alS.ProcessRuns = *jsnCfg.Process_runs } + if jsnCfg.Nested_fields != nil { + alS.NestedFields = *jsnCfg.Nested_fields + } return } diff --git a/config/chargerscfg.go b/config/chargerscfg.go index 3bee6e975..430e851da 100644 --- a/config/chargerscfg.go +++ b/config/chargerscfg.go @@ -27,6 +27,7 @@ type ChargerSCfg struct { AttributeSConns []string StringIndexedFields *[]string PrefixIndexedFields *[]string + NestedFields bool } func (cS *ChargerSCfg) loadFromJsonCfg(jsnCfg *ChargerSJsonCfg) (err error) { @@ -64,5 +65,8 @@ func (cS *ChargerSCfg) loadFromJsonCfg(jsnCfg *ChargerSJsonCfg) (err error) { } cS.PrefixIndexedFields = &pif } + if jsnCfg.Nested_fields != nil { + cS.NestedFields = *jsnCfg.Nested_fields + } return } diff --git a/config/config_defaults.go b/config/config_defaults.go index 6c815dbc9..fdc45234f 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -534,6 +534,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects":true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "nested_fields":false, // applies when indexed fields is not defined "process_runs": 1, // number of run loops when processing event }, @@ -544,6 +545,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects":true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "nested_fields":false, // applies when indexed fields is not defined }, @@ -554,6 +556,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects":true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "nested_fields":false, // applies when indexed fields is not defined }, @@ -565,6 +568,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects":true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "nested_fields":false, // applies when indexed fields is not defined }, @@ -574,6 +578,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects":true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "nested_fields":false, // applies when indexed fields is not defined }, @@ -582,6 +587,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects":true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "nested_fields":false, // applies when indexed fields is not defined "attributes_conns": [], // connections to AttributeS for altering events before supplier queries: <""|*internal|127.0.0.1:2013> "resources_conns": [], // connections to ResourceS for *res sorting, empty to disable functionality: <""|*internal|x.y.z.y:1234> "stats_conns": [], // connections to StatS for *stats sorting, empty to disable stats functionality: <""|*internal|x.y.z.y:1234> @@ -825,6 +831,7 @@ const CGRATES_CFG_JSON = ` "indexed_selects":true, // enable profile matching exclusively on indexes //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing + "nested_fields":false, // applies when indexed fields is not defined "attributes_conns": [], // connections to AttributeS for API authorization, empty to disable auth functionality: <""|*internal|x.y.z.y:1234> }, diff --git a/config/config_json_test.go b/config/config_json_test.go index 398d0967b..1b05fa2b5 100755 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -824,11 +824,12 @@ func TestDfAttributeServJsonCfg(t *testing.T) { String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, Process_runs: utils.IntPointer(1), + Nested_fields: utils.BoolPointer(false), } if cfg, err := dfCgrJsonCfg.AttributeServJsonCfg(); err != nil { t.Error(err) } else if !reflect.DeepEqual(eCfg, cfg) { - t.Error("Received: ", cfg) + t.Error("Received: ", utils.ToJSON(cfg)) } } @@ -839,11 +840,12 @@ func TestDfChargerServJsonCfg(t *testing.T) { Attributes_conns: &[]string{}, String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, + Nested_fields: utils.BoolPointer(false), } if cfg, err := dfCgrJsonCfg.ChargerServJsonCfg(); err != nil { t.Error(err) } else if !reflect.DeepEqual(eCfg, cfg) { - t.Error("Received: ", cfg) + t.Error("Received: ", utils.ToJSON(cfg)) } } @@ -868,6 +870,7 @@ func TestDfResourceLimiterSJsonCfg(t *testing.T) { Store_interval: utils.StringPointer(""), String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, + Nested_fields: utils.BoolPointer(false), } if cfg, err := dfCgrJsonCfg.ResourceSJsonCfg(); err != nil { t.Error(err) @@ -885,11 +888,12 @@ func TestDfStatServiceJsonCfg(t *testing.T) { Thresholds_conns: &[]string{}, String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, + Nested_fields: utils.BoolPointer(false), } if cfg, err := dfCgrJsonCfg.StatSJsonCfg(); err != nil { t.Error(err) } else if !reflect.DeepEqual(eCfg, cfg) { - t.Error("Received: ", cfg) + t.Error("Received: ", utils.ToJSON(cfg)) } } @@ -900,6 +904,7 @@ func TestDfThresholdSJsonCfg(t *testing.T) { Store_interval: utils.StringPointer(""), String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, + Nested_fields: utils.BoolPointer(false), } if cfg, err := dfCgrJsonCfg.ThresholdSJsonCfg(); err != nil { t.Error(err) @@ -918,11 +923,12 @@ func TestDfSupplierSJsonCfg(t *testing.T) { Resources_conns: &[]string{}, Stats_conns: &[]string{}, Default_ratio: utils.IntPointer(1), + Nested_fields: utils.BoolPointer(false), } if cfg, err := dfCgrJsonCfg.SupplierSJsonCfg(); err != nil { t.Error(err) } else if !reflect.DeepEqual(eCfg, cfg) { - t.Errorf("expecting: %+v, received: %+v", eCfg, cfg) + t.Errorf("expecting: %+v, received: %+v", utils.ToJSON(eCfg), utils.ToJSON(cfg)) } } @@ -1530,6 +1536,7 @@ func TestDfDispatcherSJsonCfg(t *testing.T) { String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, Attributes_conns: &[]string{}, + Nested_fields: utils.BoolPointer(false), } if cfg, err := dfCgrJsonCfg.DispatcherSJsonCfg(); err != nil { t.Error(err) diff --git a/config/dispatchercfg.go b/config/dispatchercfg.go index a38a7357b..01d451d23 100755 --- a/config/dispatchercfg.go +++ b/config/dispatchercfg.go @@ -27,6 +27,7 @@ type DispatcherSCfg struct { StringIndexedFields *[]string PrefixIndexedFields *[]string AttributeSConns []string + NestedFields bool } func (dps *DispatcherSCfg) loadFromJsonCfg(jsnCfg *DispatcherSJsonCfg) (err error) { @@ -64,5 +65,8 @@ func (dps *DispatcherSCfg) loadFromJsonCfg(jsnCfg *DispatcherSJsonCfg) (err erro } } } + if jsnCfg.Nested_fields != nil { + dps.NestedFields = *jsnCfg.Nested_fields + } return nil } diff --git a/config/libconfig_json.go b/config/libconfig_json.go index 62b6c5240..b8b5558d1 100755 --- a/config/libconfig_json.go +++ b/config/libconfig_json.go @@ -385,6 +385,7 @@ type AttributeSJsonCfg struct { Indexed_selects *bool String_indexed_fields *[]string Prefix_indexed_fields *[]string + Nested_fields *bool // applies when indexed fields is not defined Process_runs *int } @@ -395,6 +396,7 @@ type ChargerSJsonCfg struct { Attributes_conns *[]string String_indexed_fields *[]string Prefix_indexed_fields *[]string + Nested_fields *bool // applies when indexed fields is not defined } // ResourceLimiter service config section @@ -405,6 +407,7 @@ type ResourceSJsonCfg struct { Store_interval *string String_indexed_fields *[]string Prefix_indexed_fields *[]string + Nested_fields *bool // applies when indexed fields is not defined } // Stat service config section @@ -416,6 +419,7 @@ type StatServJsonCfg struct { Thresholds_conns *[]string String_indexed_fields *[]string Prefix_indexed_fields *[]string + Nested_fields *bool // applies when indexed fields is not defined } // Threshold service config section @@ -425,6 +429,7 @@ type ThresholdSJsonCfg struct { Store_interval *string String_indexed_fields *[]string Prefix_indexed_fields *[]string + Nested_fields *bool // applies when indexed fields is not defined } // Supplier service config section @@ -433,6 +438,7 @@ type SupplierSJsonCfg struct { Indexed_selects *bool String_indexed_fields *[]string Prefix_indexed_fields *[]string + Nested_fields *bool // applies when indexed fields is not defined Attributes_conns *[]string Resources_conns *[]string Stats_conns *[]string @@ -502,6 +508,7 @@ type DispatcherSJsonCfg struct { Indexed_selects *bool String_indexed_fields *[]string Prefix_indexed_fields *[]string + Nested_fields *bool // applies when indexed fields is not defined Attributes_conns *[]string } diff --git a/config/resourcescfg.go b/config/resourcescfg.go index fbed94d7f..4dde04ea2 100644 --- a/config/resourcescfg.go +++ b/config/resourcescfg.go @@ -31,6 +31,7 @@ type ResourceSConfig struct { StoreInterval time.Duration // Dump regularly from cache into dataDB StringIndexedFields *[]string PrefixIndexedFields *[]string + NestedFields bool } func (rlcfg *ResourceSConfig) loadFromJsonCfg(jsnCfg *ResourceSJsonCfg) (err error) { @@ -73,5 +74,8 @@ func (rlcfg *ResourceSConfig) loadFromJsonCfg(jsnCfg *ResourceSJsonCfg) (err err } rlcfg.PrefixIndexedFields = &pif } + if jsnCfg.Nested_fields != nil { + rlcfg.NestedFields = *jsnCfg.Nested_fields + } return nil } diff --git a/config/statscfg.go b/config/statscfg.go index 2aafb115c..dbe2f7ee9 100644 --- a/config/statscfg.go +++ b/config/statscfg.go @@ -32,6 +32,7 @@ type StatSCfg struct { ThresholdSConns []string StringIndexedFields *[]string PrefixIndexedFields *[]string + NestedFields bool } func (st *StatSCfg) loadFromJsonCfg(jsnCfg *StatServJsonCfg) (err error) { @@ -77,5 +78,8 @@ func (st *StatSCfg) loadFromJsonCfg(jsnCfg *StatServJsonCfg) (err error) { } st.PrefixIndexedFields = &pif } + if jsnCfg.Nested_fields != nil { + st.NestedFields = *jsnCfg.Nested_fields + } return nil } diff --git a/config/supplierscfg.go b/config/supplierscfg.go index d1c4d3f7e..81b096da9 100644 --- a/config/supplierscfg.go +++ b/config/supplierscfg.go @@ -30,6 +30,7 @@ type SupplierSCfg struct { ResourceSConns []string StatSConns []string DefaultRatio int + NestedFields bool } func (spl *SupplierSCfg) loadFromJsonCfg(jsnCfg *SupplierSJsonCfg) (err error) { @@ -92,5 +93,8 @@ func (spl *SupplierSCfg) loadFromJsonCfg(jsnCfg *SupplierSJsonCfg) (err error) { if jsnCfg.Default_ratio != nil { spl.DefaultRatio = *jsnCfg.Default_ratio } + if jsnCfg.Nested_fields != nil { + spl.NestedFields = *jsnCfg.Nested_fields + } return nil } diff --git a/config/thresholdscfg.go b/config/thresholdscfg.go index 1c23fd3a6..d72307b17 100644 --- a/config/thresholdscfg.go +++ b/config/thresholdscfg.go @@ -30,6 +30,7 @@ type ThresholdSCfg struct { StoreInterval time.Duration // Dump regularly from cache into dataDB StringIndexedFields *[]string PrefixIndexedFields *[]string + NestedFields bool } func (t *ThresholdSCfg) loadFromJsonCfg(jsnCfg *ThresholdSJsonCfg) (err error) { @@ -61,5 +62,8 @@ func (t *ThresholdSCfg) loadFromJsonCfg(jsnCfg *ThresholdSJsonCfg) (err error) { } t.PrefixIndexedFields = &pif } + if jsnCfg.Nested_fields != nil { + t.NestedFields = *jsnCfg.Nested_fields + } return nil } diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json index 15530a3d0..6f46c1c27 100755 --- a/data/conf/cgrates/cgrates.json +++ b/data/conf/cgrates/cgrates.json @@ -29,10 +29,15 @@ // "digest_separator": ",", // separator to use in replies containing data digests // "digest_equal": ":", // equal symbol used in case of digests // "rsr_separator": ";", // separator used within RSR fields +// "max_parralel_conns": 100, // the maximum number of connection used by the *parallel strategy // }, -// "rpc_conns": {}, // rpc connections definitions +// "rpc_conns": { +// "*localhost": { +// "conns": [{"address": "127.0.0.1:2012", "transport":"*json"}], +// }, +// }, // rpc connections definitions // "data_db": { // database used to store runtime data (eg: accounts) @@ -508,6 +513,7 @@ // "indexed_selects":true, // enable profile matching exclusively on indexes // //"string_indexed_fields": [], // query indexes based on these fields for faster processing // "prefix_indexed_fields": [], // query indexes based on these fields for faster processing +// "nested_fields":false, // applies when indexed fields is not defined // "process_runs": 1, // number of run loops when processing event // }, @@ -518,6 +524,7 @@ // "indexed_selects":true, // enable profile matching exclusively on indexes // //"string_indexed_fields": [], // query indexes based on these fields for faster processing // "prefix_indexed_fields": [], // query indexes based on these fields for faster processing +// "nested_fields":false, // applies when indexed fields is not defined // }, @@ -528,6 +535,7 @@ // "indexed_selects":true, // enable profile matching exclusively on indexes // //"string_indexed_fields": [], // query indexes based on these fields for faster processing // "prefix_indexed_fields": [], // query indexes based on these fields for faster processing +// "nested_fields":false, // applies when indexed fields is not defined // }, @@ -539,6 +547,7 @@ // "indexed_selects":true, // enable profile matching exclusively on indexes // //"string_indexed_fields": [], // query indexes based on these fields for faster processing // "prefix_indexed_fields": [], // query indexes based on these fields for faster processing +// "nested_fields":false, // applies when indexed fields is not defined // }, @@ -548,6 +557,7 @@ // "indexed_selects":true, // enable profile matching exclusively on indexes // //"string_indexed_fields": [], // query indexes based on these fields for faster processing // "prefix_indexed_fields": [], // query indexes based on these fields for faster processing +// "nested_fields":false, // applies when indexed fields is not defined // }, @@ -556,6 +566,7 @@ // "indexed_selects":true, // enable profile matching exclusively on indexes // //"string_indexed_fields": [], // query indexes based on these fields for faster processing // "prefix_indexed_fields": [], // query indexes based on these fields for faster processing +// "nested_fields":false, // applies when indexed fields is not defined // "attributes_conns": [], // connections to AttributeS for altering events before supplier queries: <""|*internal|127.0.0.1:2013> // "resources_conns": [], // connections to ResourceS for *res sorting, empty to disable functionality: <""|*internal|x.y.z.y:1234> // "stats_conns": [], // connections to StatS for *stats sorting, empty to disable stats functionality: <""|*internal|x.y.z.y:1234> @@ -799,6 +810,7 @@ // "indexed_selects":true, // enable profile matching exclusively on indexes // //"string_indexed_fields": [], // query indexes based on these fields for faster processing // "prefix_indexed_fields": [], // query indexes based on these fields for faster processing +// "nested_fields":false, // applies when indexed fields is not defined // "attributes_conns": [], // connections to AttributeS for API authorization, empty to disable auth functionality: <""|*internal|x.y.z.y:1234> // }, diff --git a/dispatchers/dispatchers.go b/dispatchers/dispatchers.go index fb57c5648..7a614bdc3 100755 --- a/dispatchers/dispatchers.go +++ b/dispatchers/dispatchers.go @@ -118,8 +118,10 @@ func (dS *DispatcherService) dispatcherProfileForEvent(ev *utils.CGREvent, prflIDs, err := engine.MatchingItemIDsForEvent(ev.Event, dS.cfg.DispatcherSCfg().StringIndexedFields, dS.cfg.DispatcherSCfg().PrefixIndexedFields, - dS.dm, utils.CacheDispatcherFilterIndexes, - idxKeyPrfx, dS.cfg.DispatcherSCfg().IndexedSelects) + dS.dm, utils.CacheDispatcherFilterIndexes, idxKeyPrfx, + dS.cfg.DispatcherSCfg().IndexedSelects, + dS.cfg.DispatcherSCfg().NestedFields, + ) if err != nil { // return nil, err if err != utils.ErrNotFound { @@ -128,8 +130,10 @@ func (dS *DispatcherService) dispatcherProfileForEvent(ev *utils.CGREvent, prflIDs, err = engine.MatchingItemIDsForEvent(ev.Event, dS.cfg.DispatcherSCfg().StringIndexedFields, dS.cfg.DispatcherSCfg().PrefixIndexedFields, - dS.dm, utils.CacheDispatcherFilterIndexes, - anyIdxPrfx, dS.cfg.DispatcherSCfg().IndexedSelects) + dS.dm, utils.CacheDispatcherFilterIndexes, anyIdxPrfx, + dS.cfg.DispatcherSCfg().IndexedSelects, + dS.cfg.DispatcherSCfg().NestedFields, + ) if err != nil { return nil, err } diff --git a/engine/attributes.go b/engine/attributes.go index 3494ea67c..b87bf61aa 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -68,16 +68,24 @@ func (alS *AttributeService) attributeProfileForEvent(args *AttrArgsProcessEvent if len(args.AttributeIDs) != 0 { attrIDs = args.AttributeIDs } else { - aPrflIDs, err := MatchingItemIDsForEvent(args.Event, alS.cgrcfg.AttributeSCfg().StringIndexedFields, alS.cgrcfg.AttributeSCfg().PrefixIndexedFields, - alS.dm, utils.CacheAttributeFilterIndexes, attrIdxKey, alS.filterS.cfg.AttributeSCfg().IndexedSelects) + aPrflIDs, err := MatchingItemIDsForEvent(args.Event, + alS.cgrcfg.AttributeSCfg().StringIndexedFields, + alS.cgrcfg.AttributeSCfg().PrefixIndexedFields, + alS.dm, utils.CacheAttributeFilterIndexes, attrIdxKey, + alS.cgrcfg.AttributeSCfg().IndexedSelects, + alS.cgrcfg.AttributeSCfg().NestedFields, + ) if err != nil { if err != utils.ErrNotFound { return nil, err } - if aPrflIDs, err = MatchingItemIDsForEvent(args.Event, alS.cgrcfg.AttributeSCfg().StringIndexedFields, + if aPrflIDs, err = MatchingItemIDsForEvent(args.Event, + alS.cgrcfg.AttributeSCfg().StringIndexedFields, alS.cgrcfg.AttributeSCfg().PrefixIndexedFields, - alS.dm, utils.CacheAttributeFilterIndexes, utils.ConcatenatedKey(args.Tenant, utils.META_ANY), - alS.filterS.cfg.AttributeSCfg().IndexedSelects); err != nil { + alS.dm, utils.CacheAttributeFilterIndexes, + utils.ConcatenatedKey(args.Tenant, utils.META_ANY), + alS.cgrcfg.AttributeSCfg().IndexedSelects, + alS.cgrcfg.AttributeSCfg().NestedFields); err != nil { return nil, err } } diff --git a/engine/chargers.go b/engine/chargers.go index b97d6c513..7116590c9 100644 --- a/engine/chargers.go +++ b/engine/chargers.go @@ -58,8 +58,12 @@ func (cS *ChargerService) Shutdown() (err error) { // matchingChargingProfilesForEvent returns ordered list of matching chargers which are active by the time of the function call func (cS *ChargerService) matchingChargerProfilesForEvent(cgrEv *utils.CGREventWithArgDispatcher) (cPs ChargerProfiles, err error) { cpIDs, err := MatchingItemIDsForEvent(cgrEv.Event, - cS.cfg.ChargerSCfg().StringIndexedFields, cS.cfg.ChargerSCfg().PrefixIndexedFields, - cS.dm, utils.CacheChargerFilterIndexes, cgrEv.Tenant, cS.cfg.ChargerSCfg().IndexedSelects) + cS.cfg.ChargerSCfg().StringIndexedFields, + cS.cfg.ChargerSCfg().PrefixIndexedFields, + cS.dm, utils.CacheChargerFilterIndexes, cgrEv.Tenant, + cS.cfg.ChargerSCfg().IndexedSelects, + cS.cfg.ChargerSCfg().NestedFields, + ) if err != nil { return nil, err } diff --git a/engine/filterhelpers.go b/engine/filterhelpers.go index e69aa9040..7ab603cf6 100644 --- a/engine/filterhelpers.go +++ b/engine/filterhelpers.go @@ -30,7 +30,7 @@ import ( // fieldIDs limits the fields which are checked against indexes // helper on top of dataDB.MatchFilterIndex, adding utils.ANY to list of fields queried func MatchingItemIDsForEvent(ev map[string]interface{}, stringFldIDs, prefixFldIDs *[]string, - dm *DataManager, cacheID, itemIDPrefix string, indexedSelects bool) (itemIDs utils.StringMap, err error) { + dm *DataManager, cacheID, itemIDPrefix string, indexedSelects, nestedFields bool) (itemIDs utils.StringMap, err error) { itemIDs = make(utils.StringMap) // Guard will protect the function with automatic locking diff --git a/engine/filterhelpers_test.go b/engine/filterhelpers_test.go index b63cbd01f..df152224b 100644 --- a/engine/filterhelpers_test.go +++ b/engine/filterhelpers_test.go @@ -82,7 +82,7 @@ func TestFilterMatchingItemIDsForEvent(t *testing.T) { "Field": "profile", } aPrflIDs, err := MatchingItemIDsForEvent(matchEV, nil, nil, - dmMatch, utils.CacheAttributeFilterIndexes, prefix, true) + dmMatch, utils.CacheAttributeFilterIndexes, prefix, true, false) if err != nil { t.Errorf("Error: %+v", err) } @@ -94,7 +94,7 @@ func TestFilterMatchingItemIDsForEvent(t *testing.T) { "Field": "profilePrefix", } aPrflIDs, err = MatchingItemIDsForEvent(matchEV, nil, nil, - dmMatch, utils.CacheAttributeFilterIndexes, prefix, true) + dmMatch, utils.CacheAttributeFilterIndexes, prefix, true, false) if err != nil { t.Errorf("Error: %+v", err) } diff --git a/engine/resources.go b/engine/resources.go index b7c3f29fc..c6ffb9d47 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -457,8 +457,13 @@ func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREvent, } rIDs = x.(utils.StringMap) } else { // select the resourceIDs out of dataDB - rIDs, err = MatchingItemIDsForEvent(ev.Event, rS.cgrcfg.ResourceSCfg().StringIndexedFields, rS.cgrcfg.ResourceSCfg().PrefixIndexedFields, - rS.dm, utils.CacheResourceFilterIndexes, ev.Tenant, rS.filterS.cfg.ResourceSCfg().IndexedSelects) + rIDs, err = MatchingItemIDsForEvent(ev.Event, + rS.cgrcfg.ResourceSCfg().StringIndexedFields, + rS.cgrcfg.ResourceSCfg().PrefixIndexedFields, + rS.dm, utils.CacheResourceFilterIndexes, ev.Tenant, + rS.cgrcfg.ResourceSCfg().IndexedSelects, + rS.cgrcfg.ResourceSCfg().NestedFields, + ) } if err != nil { if err == utils.ErrNotFound { diff --git a/engine/resources_test.go b/engine/resources_test.go index f0d3266d5..9ed0415da 100644 --- a/engine/resources_test.go +++ b/engine/resources_test.go @@ -647,7 +647,7 @@ func TestResourceUsageTTLCase4(t *testing.T) { func TestResourceMatchWithIndexFalse(t *testing.T) { Cache.Clear(nil) - resService.filterS.cfg.ResourceSCfg().IndexedSelects = false + resService.cgrcfg.ResourceSCfg().IndexedSelects = false mres, err := resService.matchingResourcesForEvent(resEvs[0], "TestResourceMatchWithIndexFalse1", &timeDurationExample) if err != nil { diff --git a/engine/stats.go b/engine/stats.go index f05abfe92..65d0b8573 100644 --- a/engine/stats.go +++ b/engine/stats.go @@ -156,8 +156,13 @@ func (sS *StatService) matchingStatQueuesForEvent(args *StatsArgsProcessEvent) ( if len(args.StatIDs) != 0 { sqIDs = args.StatIDs } else { - mapIDs, err := MatchingItemIDsForEvent(args.Event, sS.cgrcfg.StatSCfg().StringIndexedFields, sS.cgrcfg.StatSCfg().PrefixIndexedFields, - sS.dm, utils.CacheStatFilterIndexes, args.Tenant, sS.filterS.cfg.StatSCfg().IndexedSelects) + mapIDs, err := MatchingItemIDsForEvent(args.Event, + sS.cgrcfg.StatSCfg().StringIndexedFields, + sS.cgrcfg.StatSCfg().PrefixIndexedFields, + sS.dm, utils.CacheStatFilterIndexes, args.Tenant, + sS.cgrcfg.StatSCfg().IndexedSelects, + sS.cgrcfg.StatSCfg().NestedFields, + ) if err != nil { return nil, err } diff --git a/engine/stats_test.go b/engine/stats_test.go index beb1c9833..fd72abcf0 100644 --- a/engine/stats_test.go +++ b/engine/stats_test.go @@ -323,7 +323,7 @@ func TestStatQueuesProcessEvent(t *testing.T) { } func TestStatQueuesMatchWithIndexFalse(t *testing.T) { - statService.filterS.cfg.StatSCfg().IndexedSelects = false + statService.cgrcfg.StatSCfg().IndexedSelects = false msq, err := statService.matchingStatQueuesForEvent(statsEvs[0]) if err != nil { t.Errorf("Error: %+v", err) diff --git a/engine/suppliers.go b/engine/suppliers.go index abd13dba9..4cb63fde9 100644 --- a/engine/suppliers.go +++ b/engine/suppliers.go @@ -147,8 +147,13 @@ func (spS *SupplierService) Shutdown() error { // matchingSupplierProfilesForEvent returns ordered list of matching resources which are active by the time of the call func (spS *SupplierService) matchingSupplierProfilesForEvent(ev *utils.CGREvent, singleResult bool) (matchingSLP []*SupplierProfile, err error) { - sPrflIDs, err := MatchingItemIDsForEvent(ev.Event, spS.cgrcfg.SupplierSCfg().StringIndexedFields, spS.cgrcfg.SupplierSCfg().PrefixIndexedFields, - spS.dm, utils.CacheSupplierFilterIndexes, ev.Tenant, spS.filterS.cfg.SupplierSCfg().IndexedSelects) + sPrflIDs, err := MatchingItemIDsForEvent(ev.Event, + spS.cgrcfg.SupplierSCfg().StringIndexedFields, + spS.cgrcfg.SupplierSCfg().PrefixIndexedFields, + spS.dm, utils.CacheSupplierFilterIndexes, ev.Tenant, + spS.cgrcfg.SupplierSCfg().IndexedSelects, + spS.cgrcfg.SupplierSCfg().NestedFields, + ) if err != nil { return nil, err } diff --git a/engine/suppliers_test.go b/engine/suppliers_test.go index 357e9d905..10305cfae 100644 --- a/engine/suppliers_test.go +++ b/engine/suppliers_test.go @@ -630,7 +630,7 @@ func TestSuppliersAsOptsGetSuppliersMaxCost(t *testing.T) { } func TestSuppliersMatchWithIndexFalse(t *testing.T) { - splService.filterS.cfg.SupplierSCfg().IndexedSelects = false + splService.cgrcfg.SupplierSCfg().IndexedSelects = false sprf, err := splService.matchingSupplierProfilesForEvent(argsGetSuppliers[0].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) diff --git a/engine/thresholds.go b/engine/thresholds.go index a6b80de80..cf702c3ed 100644 --- a/engine/thresholds.go +++ b/engine/thresholds.go @@ -228,9 +228,13 @@ func (tS *ThresholdService) matchingThresholdsForEvent(args *ArgsProcessEvent) ( if len(args.ThresholdIDs) != 0 { tIDs = args.ThresholdIDs } else { - tIDsMap, err := MatchingItemIDsForEvent(args.Event, tS.cgrcfg.ThresholdSCfg().StringIndexedFields, - tS.cgrcfg.ThresholdSCfg().PrefixIndexedFields, tS.dm, utils.CacheThresholdFilterIndexes, - args.Tenant, tS.filterS.cfg.ThresholdSCfg().IndexedSelects) + tIDsMap, err := MatchingItemIDsForEvent(args.Event, + tS.cgrcfg.ThresholdSCfg().StringIndexedFields, + tS.cgrcfg.ThresholdSCfg().PrefixIndexedFields, + tS.dm, utils.CacheThresholdFilterIndexes, args.Tenant, + tS.cgrcfg.ThresholdSCfg().IndexedSelects, + tS.cgrcfg.ThresholdSCfg().NestedFields, + ) if err != nil { return nil, err }