From dfda3ffe72f2a74df85a14eeb221c59e5aae5371 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 12 Mar 2019 10:34:35 +0200 Subject: [PATCH] Added indexed_selects option per subsystem --- config/attributescfg.go | 4 ++++ config/chargerscfg.go | 4 ++++ config/config_defaults.go | 8 +++++++- config/config_json_test.go | 8 +++++++- config/config_test.go | 7 ++++++- config/dispatchercfg.go | 4 ++++ config/filterscfg.go | 4 ---- config/filterscfg_test.go | 4 +--- config/libconfig_json.go | 8 +++++++- config/{reslimitercfg.go => resourcescfg.go} | 4 ++++ config/{reslimitercfg_test.go => resourcescfg_test.go} | 0 config/statscfg.go | 4 ++++ config/supplierscfg.go | 4 ++++ config/thresholdscfg.go | 4 ++++ data/conf/cgrates/cgrates.json | 8 +++++++- data/conf/samples/filters/cgrates.json | 4 +++- dispatchers/dispatchers.go | 4 ++-- engine/attributes.go | 4 ++-- engine/chargers.go | 2 +- engine/resources.go | 2 +- engine/resources_test.go | 2 +- engine/stats.go | 2 +- engine/stats_test.go | 2 +- engine/suppliers.go | 2 +- engine/suppliers_test.go | 2 +- engine/thresholds.go | 2 +- 26 files changed, 78 insertions(+), 25 deletions(-) rename config/{reslimitercfg.go => resourcescfg.go} (94%) rename config/{reslimitercfg_test.go => resourcescfg_test.go} (100%) diff --git a/config/attributescfg.go b/config/attributescfg.go index d39125524..6b2b261a6 100644 --- a/config/attributescfg.go +++ b/config/attributescfg.go @@ -21,6 +21,7 @@ package config // AttributeSCfg is the configuration of attribute service type AttributeSCfg struct { Enabled bool + IndexedSelects bool StringIndexedFields *[]string PrefixIndexedFields *[]string ProcessRuns int @@ -33,6 +34,9 @@ func (alS *AttributeSCfg) loadFromJsonCfg(jsnCfg *AttributeSJsonCfg) (err error) if jsnCfg.Enabled != nil { alS.Enabled = *jsnCfg.Enabled } + if jsnCfg.Indexed_selects != nil { + alS.IndexedSelects = *jsnCfg.Indexed_selects + } if jsnCfg.String_indexed_fields != nil { sif := make([]string, len(*jsnCfg.String_indexed_fields)) for i, fID := range *jsnCfg.String_indexed_fields { diff --git a/config/chargerscfg.go b/config/chargerscfg.go index 074332a59..6e73acdc3 100644 --- a/config/chargerscfg.go +++ b/config/chargerscfg.go @@ -21,6 +21,7 @@ package config // SupplierSCfg is the configuration of supplier service type ChargerSCfg struct { Enabled bool + IndexedSelects bool AttributeSConns []*HaPoolConfig StringIndexedFields *[]string PrefixIndexedFields *[]string @@ -33,6 +34,9 @@ func (cS *ChargerSCfg) loadFromJsonCfg(jsnCfg *ChargerSJsonCfg) (err error) { if jsnCfg.Enabled != nil { cS.Enabled = *jsnCfg.Enabled } + if jsnCfg.Indexed_selects != nil { + cS.IndexedSelects = *jsnCfg.Indexed_selects + } if jsnCfg.Attributes_conns != nil { cS.AttributeSConns = make([]*HaPoolConfig, len(*jsnCfg.Attributes_conns)) for idx, jsnHaCfg := range *jsnCfg.Attributes_conns { diff --git a/config/config_defaults.go b/config/config_defaults.go index a1eac4f72..b3f3ceb7a 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -154,7 +154,6 @@ const CGRATES_CFG_JSON = ` "filters": { // Filters configuration (*new) "stats_conns": [], // connections to StatS for <*stats> filters, empty to disable stats functionality: <""|*internal|x.y.z.y:1234> "resources_conns": [], // connections to ResourceS for <*resources> filters, empty to disable stats functionality: <""|*internal|x.y.z.y:1234> - "indexed_selects":true, // enable profile matching exclusively on indexes }, @@ -448,6 +447,7 @@ const CGRATES_CFG_JSON = ` "attributes": { // AttributeS config "enabled": false, // starts attribute service: . + "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 "process_runs": 1, // number of run loops when processing event @@ -456,6 +456,7 @@ const CGRATES_CFG_JSON = ` "chargers": { // ChargerS config "enabled": false, // starts charger service: . + "indexed_selects":true, // enable profile matching exclusively on indexes "attributes_conns": [], // connections to AttributeS for event fields altering <""|127.0.0.1:2013> //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing @@ -464,6 +465,7 @@ const CGRATES_CFG_JSON = ` "resources": { // ResourceS config "enabled": false, // starts ResourceLimiter service: . + "indexed_selects":true, // enable profile matching exclusively on indexes "store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur> "thresholds_conns": [], // connections to ThresholdS for resource reporting, empty to disable thresholds functionality: <""|*internal|x.y.z.y:1234> //"string_indexed_fields": [], // query indexes based on these fields for faster processing @@ -473,6 +475,7 @@ const CGRATES_CFG_JSON = ` "stats": { // StatS config "enabled": false, // starts Stat service: . + "indexed_selects":true, // enable profile matching exclusively on indexes "store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur> "thresholds_conns": [], // connections to ThresholdS for StatUpdates, empty to disable thresholds functionality: <""|*internal|x.y.z.y:1234> //"string_indexed_fields": [], // query indexes based on these fields for faster processing @@ -482,6 +485,7 @@ const CGRATES_CFG_JSON = ` "thresholds": { // ThresholdS "enabled": false, // starts ThresholdS service: . + "indexed_selects":true, // enable profile matching exclusively on indexes "store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur> //"string_indexed_fields": [], // query indexes based on these fields for faster processing "prefix_indexed_fields": [], // query indexes based on these fields for faster processing @@ -490,6 +494,7 @@ const CGRATES_CFG_JSON = ` "suppliers": { // SupplierS config "enabled": false, // starts SupplierS service: . + "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 "attributes_conns": [], // connections to AttributeS for altering events before supplier queries: <""|*internal|127.0.0.1:2013> @@ -726,6 +731,7 @@ const CGRATES_CFG_JSON = ` "dispatchers":{ // DispatcherS config "enabled": false, // starts DispatcherS service: . + "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 "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 1d7248430..add260d4e 100755 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -727,6 +727,7 @@ func TestHttpAgentJsonCfg(t *testing.T) { func TestDfAttributeServJsonCfg(t *testing.T) { eCfg := &AttributeSJsonCfg{ Enabled: utils.BoolPointer(false), + Indexed_selects: utils.BoolPointer(true), String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, Process_runs: utils.IntPointer(1), @@ -741,6 +742,7 @@ func TestDfAttributeServJsonCfg(t *testing.T) { func TestDfChargerServJsonCfg(t *testing.T) { eCfg := &ChargerSJsonCfg{ Enabled: utils.BoolPointer(false), + Indexed_selects: utils.BoolPointer(true), Attributes_conns: &[]*HaPoolJsonCfg{}, String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, @@ -756,7 +758,6 @@ func TestDfFilterSJsonCfg(t *testing.T) { eCfg := &FilterSJsonCfg{ Stats_conns: &[]*HaPoolJsonCfg{}, Resources_conns: &[]*HaPoolJsonCfg{}, - Indexed_selects: utils.BoolPointer(true), } if cfg, err := dfCgrJsonCfg.FilterSJsonCfg(); err != nil { t.Error(err) @@ -768,6 +769,7 @@ func TestDfFilterSJsonCfg(t *testing.T) { func TestDfResourceLimiterSJsonCfg(t *testing.T) { eCfg := &ResourceSJsonCfg{ Enabled: utils.BoolPointer(false), + Indexed_selects: utils.BoolPointer(true), Thresholds_conns: &[]*HaPoolJsonCfg{}, Store_interval: utils.StringPointer(""), String_indexed_fields: nil, @@ -783,6 +785,7 @@ func TestDfResourceLimiterSJsonCfg(t *testing.T) { func TestDfStatServiceJsonCfg(t *testing.T) { eCfg := &StatServJsonCfg{ Enabled: utils.BoolPointer(false), + Indexed_selects: utils.BoolPointer(true), Store_interval: utils.StringPointer(""), Thresholds_conns: &[]*HaPoolJsonCfg{}, String_indexed_fields: nil, @@ -798,6 +801,7 @@ func TestDfStatServiceJsonCfg(t *testing.T) { func TestDfThresholdSJsonCfg(t *testing.T) { eCfg := &ThresholdSJsonCfg{ Enabled: utils.BoolPointer(false), + Indexed_selects: utils.BoolPointer(true), Store_interval: utils.StringPointer(""), String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, @@ -812,6 +816,7 @@ func TestDfThresholdSJsonCfg(t *testing.T) { func TestDfSupplierSJsonCfg(t *testing.T) { eCfg := &SupplierSJsonCfg{ Enabled: utils.BoolPointer(false), + Indexed_selects: utils.BoolPointer(true), String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, Attributes_conns: &[]*HaPoolJsonCfg{}, @@ -1392,6 +1397,7 @@ func TestDfHttpJsonCfg(t *testing.T) { func TestDfDispatcherSJsonCfg(t *testing.T) { eCfg := &DispatcherSJsonCfg{ Enabled: utils.BoolPointer(false), + Indexed_selects: utils.BoolPointer(true), String_indexed_fields: nil, Prefix_indexed_fields: &[]string{}, Attributes_conns: &[]*HaPoolJsonCfg{}, diff --git a/config/config_test.go b/config/config_test.go index a788cac90..7e98da885 100755 --- a/config/config_test.go +++ b/config/config_test.go @@ -772,7 +772,6 @@ func TestCgrCfgJSONDefaultFiltersCfg(t *testing.T) { eFiltersCfg := &FilterSCfg{ StatSConns: []*HaPoolConfig{}, ResourceSConns: []*HaPoolConfig{}, - IndexedSelects: true, } if !reflect.DeepEqual(cgrCfg.filterSCfg, eFiltersCfg) { t.Errorf("received: %+v, expecting: %+v", cgrCfg.filterSCfg, eFiltersCfg) @@ -782,6 +781,7 @@ func TestCgrCfgJSONDefaultFiltersCfg(t *testing.T) { func TestCgrCfgJSONDefaultSChargerSCfg(t *testing.T) { eChargerSCfg := &ChargerSCfg{ Enabled: false, + IndexedSelects: true, AttributeSConns: []*HaPoolConfig{}, StringIndexedFields: nil, PrefixIndexedFields: &[]string{}, @@ -794,6 +794,7 @@ func TestCgrCfgJSONDefaultSChargerSCfg(t *testing.T) { func TestCgrCfgJSONDefaultsResLimCfg(t *testing.T) { eResLiCfg := &ResourceSConfig{ Enabled: false, + IndexedSelects: true, ThresholdSConns: []*HaPoolConfig{}, StoreInterval: 0, StringIndexedFields: nil, @@ -808,6 +809,7 @@ func TestCgrCfgJSONDefaultsResLimCfg(t *testing.T) { func TestCgrCfgJSONDefaultStatsCfg(t *testing.T) { eStatsCfg := &StatSCfg{ Enabled: false, + IndexedSelects: true, StoreInterval: 0, ThresholdSConns: []*HaPoolConfig{}, StringIndexedFields: nil, @@ -821,6 +823,7 @@ func TestCgrCfgJSONDefaultStatsCfg(t *testing.T) { func TestCgrCfgJSONDefaultThresholdSCfg(t *testing.T) { eThresholdSCfg := &ThresholdSCfg{ Enabled: false, + IndexedSelects: true, StoreInterval: 0, StringIndexedFields: nil, PrefixIndexedFields: &[]string{}, @@ -833,6 +836,7 @@ func TestCgrCfgJSONDefaultThresholdSCfg(t *testing.T) { func TestCgrCfgJSONDefaultSupplierSCfg(t *testing.T) { eSupplSCfg := &SupplierSCfg{ Enabled: false, + IndexedSelects: true, StringIndexedFields: nil, PrefixIndexedFields: &[]string{}, AttributeSConns: []*HaPoolConfig{}, @@ -1457,6 +1461,7 @@ func TestCgrLoaderCfgITDefaults(t *testing.T) { func TestCgrCfgJSONDefaultDispatcherSCfg(t *testing.T) { eDspSCfg := &DispatcherSCfg{ Enabled: false, + IndexedSelects: true, StringIndexedFields: nil, PrefixIndexedFields: &[]string{}, AttributeSConns: []*HaPoolConfig{}, diff --git a/config/dispatchercfg.go b/config/dispatchercfg.go index 03ef7e9e0..d57a8f9b5 100755 --- a/config/dispatchercfg.go +++ b/config/dispatchercfg.go @@ -21,6 +21,7 @@ package config // DispatcherSCfg is the configuration of dispatcher service type DispatcherSCfg struct { Enabled bool + IndexedSelects bool StringIndexedFields *[]string PrefixIndexedFields *[]string AttributeSConns []*HaPoolConfig @@ -34,6 +35,9 @@ func (dps *DispatcherSCfg) loadFromJsonCfg(jsnCfg *DispatcherSJsonCfg) (err erro if jsnCfg.Enabled != nil { dps.Enabled = *jsnCfg.Enabled } + if jsnCfg.Indexed_selects != nil { + dps.IndexedSelects = *jsnCfg.Indexed_selects + } if jsnCfg.String_indexed_fields != nil { sif := make([]string, len(*jsnCfg.String_indexed_fields)) for i, fID := range *jsnCfg.String_indexed_fields { diff --git a/config/filterscfg.go b/config/filterscfg.go index c34e614a2..ea5ddbfb0 100644 --- a/config/filterscfg.go +++ b/config/filterscfg.go @@ -21,7 +21,6 @@ package config type FilterSCfg struct { StatSConns []*HaPoolConfig ResourceSConns []*HaPoolConfig - IndexedSelects bool } func (fSCfg *FilterSCfg) loadFromJsonCfg(jsnCfg *FilterSJsonCfg) (err error) { @@ -42,8 +41,5 @@ func (fSCfg *FilterSCfg) loadFromJsonCfg(jsnCfg *FilterSJsonCfg) (err error) { fSCfg.ResourceSConns[idx].loadFromJsonCfg(jsnHaCfg) } } - if jsnCfg.Indexed_selects != nil { - fSCfg.IndexedSelects = *jsnCfg.Indexed_selects - } return } diff --git a/config/filterscfg_test.go b/config/filterscfg_test.go index 8ed46266e..3e4abcbc2 100644 --- a/config/filterscfg_test.go +++ b/config/filterscfg_test.go @@ -40,12 +40,10 @@ func TestFilterSCfgloadFromJsonCfg(t *testing.T) { cfgJSONStr := `{ "filters": { // Filters configuration (*new) "stats_conns": [{"Address":"127.0.0.1","Transport":"","Synchronous":true}], // address where to reach the stat service, empty to disable stats functionality: <""|*internal|x.y.z.y:1234> - "indexed_selects":true, // enable profile matching exclusively on indexes }, }` expected = FilterSCfg{ - IndexedSelects: true, - StatSConns: []*HaPoolConfig{{Address: "127.0.0.1", Transport: "", Synchronous: true}}, + StatSConns: []*HaPoolConfig{{Address: "127.0.0.1", Transport: "", Synchronous: true}}, } if jsnCfg, err := NewCgrJsonCfgFromReader(strings.NewReader(cfgJSONStr)); err != nil { t.Error(err) diff --git a/config/libconfig_json.go b/config/libconfig_json.go index 08b1722fe..c051f0833 100755 --- a/config/libconfig_json.go +++ b/config/libconfig_json.go @@ -92,7 +92,6 @@ type DbJsonCfg struct { // Filters config type FilterSJsonCfg struct { Stats_conns *[]*HaPoolJsonCfg - Indexed_selects *bool Resources_conns *[]*HaPoolJsonCfg } @@ -404,6 +403,7 @@ type HistServJsonCfg struct { // Attribute service config section type AttributeSJsonCfg struct { Enabled *bool + Indexed_selects *bool String_indexed_fields *[]string Prefix_indexed_fields *[]string Process_runs *int @@ -412,6 +412,7 @@ type AttributeSJsonCfg struct { // ChargerSJsonCfg service config section type ChargerSJsonCfg struct { Enabled *bool + Indexed_selects *bool Attributes_conns *[]*HaPoolJsonCfg String_indexed_fields *[]string Prefix_indexed_fields *[]string @@ -420,6 +421,7 @@ type ChargerSJsonCfg struct { // ResourceLimiter service config section type ResourceSJsonCfg struct { Enabled *bool + Indexed_selects *bool Thresholds_conns *[]*HaPoolJsonCfg Store_interval *string String_indexed_fields *[]string @@ -429,6 +431,7 @@ type ResourceSJsonCfg struct { // Stat service config section type StatServJsonCfg struct { Enabled *bool + Indexed_selects *bool Store_interval *string Thresholds_conns *[]*HaPoolJsonCfg String_indexed_fields *[]string @@ -438,6 +441,7 @@ type StatServJsonCfg struct { // Threshold service config section type ThresholdSJsonCfg struct { Enabled *bool + Indexed_selects *bool Store_interval *string String_indexed_fields *[]string Prefix_indexed_fields *[]string @@ -446,6 +450,7 @@ type ThresholdSJsonCfg struct { // Supplier service config section type SupplierSJsonCfg struct { Enabled *bool + Indexed_selects *bool String_indexed_fields *[]string Prefix_indexed_fields *[]string Attributes_conns *[]*HaPoolJsonCfg @@ -514,6 +519,7 @@ type SureTaxJsonCfg struct { type DispatcherSJsonCfg struct { Enabled *bool + Indexed_selects *bool String_indexed_fields *[]string Prefix_indexed_fields *[]string Attributes_conns *[]*HaPoolJsonCfg diff --git a/config/reslimitercfg.go b/config/resourcescfg.go similarity index 94% rename from config/reslimitercfg.go rename to config/resourcescfg.go index c0c3470b3..0897f75ca 100644 --- a/config/reslimitercfg.go +++ b/config/resourcescfg.go @@ -26,6 +26,7 @@ import ( type ResourceSConfig struct { Enabled bool + IndexedSelects bool ThresholdSConns []*HaPoolConfig // Connections towards StatS StoreInterval time.Duration // Dump regularly from cache into dataDB StringIndexedFields *[]string @@ -39,6 +40,9 @@ func (rlcfg *ResourceSConfig) loadFromJsonCfg(jsnCfg *ResourceSJsonCfg) (err err if jsnCfg.Enabled != nil { rlcfg.Enabled = *jsnCfg.Enabled } + if jsnCfg.Indexed_selects != nil { + rlcfg.IndexedSelects = *jsnCfg.Indexed_selects + } if jsnCfg.Thresholds_conns != nil { rlcfg.ThresholdSConns = make([]*HaPoolConfig, len(*jsnCfg.Thresholds_conns)) for idx, jsnHaCfg := range *jsnCfg.Thresholds_conns { diff --git a/config/reslimitercfg_test.go b/config/resourcescfg_test.go similarity index 100% rename from config/reslimitercfg_test.go rename to config/resourcescfg_test.go diff --git a/config/statscfg.go b/config/statscfg.go index 5d36cef26..f466e0180 100644 --- a/config/statscfg.go +++ b/config/statscfg.go @@ -26,6 +26,7 @@ import ( type StatSCfg struct { Enabled bool + IndexedSelects bool StoreInterval time.Duration // Dump regularly from cache into dataDB ThresholdSConns []*HaPoolConfig StringIndexedFields *[]string @@ -39,6 +40,9 @@ func (st *StatSCfg) loadFromJsonCfg(jsnCfg *StatServJsonCfg) (err error) { if jsnCfg.Enabled != nil { st.Enabled = *jsnCfg.Enabled } + if jsnCfg.Indexed_selects != nil { + st.IndexedSelects = *jsnCfg.Indexed_selects + } if jsnCfg.Store_interval != nil { if st.StoreInterval, err = utils.ParseDurationWithNanosecs(*jsnCfg.Store_interval); err != nil { return err diff --git a/config/supplierscfg.go b/config/supplierscfg.go index 702a529b0..8f0cd511a 100644 --- a/config/supplierscfg.go +++ b/config/supplierscfg.go @@ -21,6 +21,7 @@ package config // SupplierSCfg is the configuration of supplier service type SupplierSCfg struct { Enabled bool + IndexedSelects bool StringIndexedFields *[]string PrefixIndexedFields *[]string AttributeSConns []*HaPoolConfig @@ -36,6 +37,9 @@ func (spl *SupplierSCfg) loadFromJsonCfg(jsnCfg *SupplierSJsonCfg) (err error) { if jsnCfg.Enabled != nil { spl.Enabled = *jsnCfg.Enabled } + if jsnCfg.Indexed_selects != nil { + spl.IndexedSelects = *jsnCfg.Indexed_selects + } if jsnCfg.String_indexed_fields != nil { sif := make([]string, len(*jsnCfg.String_indexed_fields)) for i, fID := range *jsnCfg.String_indexed_fields { diff --git a/config/thresholdscfg.go b/config/thresholdscfg.go index 318c4ba08..1c23fd3a6 100644 --- a/config/thresholdscfg.go +++ b/config/thresholdscfg.go @@ -26,6 +26,7 @@ import ( type ThresholdSCfg struct { Enabled bool + IndexedSelects bool StoreInterval time.Duration // Dump regularly from cache into dataDB StringIndexedFields *[]string PrefixIndexedFields *[]string @@ -38,6 +39,9 @@ func (t *ThresholdSCfg) loadFromJsonCfg(jsnCfg *ThresholdSJsonCfg) (err error) { if jsnCfg.Enabled != nil { t.Enabled = *jsnCfg.Enabled } + if jsnCfg.Indexed_selects != nil { + t.IndexedSelects = *jsnCfg.Indexed_selects + } if jsnCfg.Store_interval != nil { if t.StoreInterval, err = utils.ParseDurationWithNanosecs(*jsnCfg.Store_interval); err != nil { return err diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json index 3bf7f3a0c..4abd3d256 100644 --- a/data/conf/cgrates/cgrates.json +++ b/data/conf/cgrates/cgrates.json @@ -133,7 +133,6 @@ // "filters": { // Filters configuration (*new) // "stats_conns": [], // connections to StatS for <*stats> filters, empty to disable stats functionality: <""|*internal|x.y.z.y:1234> // "resources_conns": [], // connections to ResourceS for <*resources> filters, empty to disable stats functionality: <""|*internal|x.y.z.y:1234> -// "indexed_selects":true, // enable profile matching exclusively on indexes // }, @@ -427,6 +426,7 @@ // "attributes": { // AttributeS config // "enabled": false, // starts attribute service: . +// "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 // "process_runs": 1, // number of run loops when processing event @@ -435,6 +435,7 @@ // "chargers": { // ChargerS config // "enabled": false, // starts charger service: . +// "indexed_selects":true, // enable profile matching exclusively on indexes // "attributes_conns": [], // connections to AttributeS for event fields altering <""|127.0.0.1:2013> // //"string_indexed_fields": [], // query indexes based on these fields for faster processing // "prefix_indexed_fields": [], // query indexes based on these fields for faster processing @@ -443,6 +444,7 @@ // "resources": { // ResourceS config // "enabled": false, // starts ResourceLimiter service: . +// "indexed_selects":true, // enable profile matching exclusively on indexes // "store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur> // "thresholds_conns": [], // connections to ThresholdS for resource reporting, empty to disable thresholds functionality: <""|*internal|x.y.z.y:1234> // //"string_indexed_fields": [], // query indexes based on these fields for faster processing @@ -452,6 +454,7 @@ // "stats": { // StatS config // "enabled": false, // starts Stat service: . +// "indexed_selects":true, // enable profile matching exclusively on indexes // "store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur> // "thresholds_conns": [], // connections to ThresholdS for StatUpdates, empty to disable thresholds functionality: <""|*internal|x.y.z.y:1234> // //"string_indexed_fields": [], // query indexes based on these fields for faster processing @@ -461,6 +464,7 @@ // "thresholds": { // ThresholdS // "enabled": false, // starts ThresholdS service: . +// "indexed_selects":true, // enable profile matching exclusively on indexes // "store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur> // //"string_indexed_fields": [], // query indexes based on these fields for faster processing // "prefix_indexed_fields": [], // query indexes based on these fields for faster processing @@ -469,6 +473,7 @@ // "suppliers": { // SupplierS config // "enabled": false, // starts SupplierS service: . +// "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 // "attributes_conns": [], // connections to AttributeS for altering events before supplier queries: <""|*internal|127.0.0.1:2013> @@ -705,6 +710,7 @@ // "dispatchers":{ // DispatcherS config // "enabled": false, // starts DispatcherS service: . +// "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 // "attributes_conns": [], // connections to AttributeS for API authorization, empty to disable auth functionality: <""|*internal|x.y.z.y:1234> diff --git a/data/conf/samples/filters/cgrates.json b/data/conf/samples/filters/cgrates.json index f40a7859e..c9238cb1d 100644 --- a/data/conf/samples/filters/cgrates.json +++ b/data/conf/samples/filters/cgrates.json @@ -43,24 +43,26 @@ "resources_conns": [ {"address": "127.0.0.1:2012", "transport":"*json"}, ], - "indexed_selects":false, }, "resources": { "enabled": true, + "indexed_selects":false, "store_interval": "1s", }, "stats": { "enabled": true, + "indexed_selects":false, "store_interval": "1s", }, "thresholds": { "enabled": true, + "indexed_selects":false, "store_interval": "1s", }, diff --git a/dispatchers/dispatchers.go b/dispatchers/dispatchers.go index 0924da336..046342f59 100755 --- a/dispatchers/dispatchers.go +++ b/dispatchers/dispatchers.go @@ -81,7 +81,7 @@ func (dS *DispatcherService) dispatcherForEvent(ev *utils.CGREvent, dS.cfg.DispatcherSCfg().StringIndexedFields, dS.cfg.DispatcherSCfg().PrefixIndexedFields, dS.dm, utils.CacheDispatcherFilterIndexes, - idxKeyPrfx, dS.cfg.FilterSCfg().IndexedSelects) + idxKeyPrfx, dS.cfg.DispatcherSCfg().IndexedSelects) if err != nil { // return nil, err if err != utils.ErrNotFound { @@ -91,7 +91,7 @@ func (dS *DispatcherService) dispatcherForEvent(ev *utils.CGREvent, dS.cfg.DispatcherSCfg().StringIndexedFields, dS.cfg.DispatcherSCfg().PrefixIndexedFields, dS.dm, utils.CacheDispatcherFilterIndexes, - anyIdxPrfx, dS.cfg.FilterSCfg().IndexedSelects) + anyIdxPrfx, dS.cfg.DispatcherSCfg().IndexedSelects) if err != nil { return nil, err } diff --git a/engine/attributes.go b/engine/attributes.go index 3c14f849b..f122cca9f 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -69,14 +69,14 @@ func (alS *AttributeService) attributeProfileForEvent(args *AttrArgsProcessEvent attrIDs = args.AttributeIDs } else { aPrflIDs, err := MatchingItemIDsForEvent(args.Event, alS.stringIndexedFields, alS.prefixIndexedFields, - alS.dm, utils.CacheAttributeFilterIndexes, attrIdxKey, alS.filterS.cfg.FilterSCfg().IndexedSelects) + alS.dm, utils.CacheAttributeFilterIndexes, attrIdxKey, alS.filterS.cfg.AttributeSCfg().IndexedSelects) if err != nil { if err != utils.ErrNotFound { return nil, err } if aPrflIDs, err = MatchingItemIDsForEvent(args.Event, alS.stringIndexedFields, alS.prefixIndexedFields, alS.dm, utils.CacheAttributeFilterIndexes, utils.ConcatenatedKey(args.Tenant, utils.META_ANY), - alS.filterS.cfg.FilterSCfg().IndexedSelects); err != nil { + alS.filterS.cfg.AttributeSCfg().IndexedSelects); err != nil { return nil, err } } diff --git a/engine/chargers.go b/engine/chargers.go index 559c0bed7..f905985a2 100644 --- a/engine/chargers.go +++ b/engine/chargers.go @@ -65,7 +65,7 @@ func (cS *ChargerService) Shutdown() (err error) { func (cS *ChargerService) matchingChargerProfilesForEvent(cgrEv *utils.CGREvent) (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.FilterSCfg().IndexedSelects) + cS.dm, utils.CacheChargerFilterIndexes, cgrEv.Tenant, cS.cfg.ChargerSCfg().IndexedSelects) if err != nil { return nil, err } diff --git a/engine/resources.go b/engine/resources.go index 1a1ce8194..befbc0f7d 100644 --- a/engine/resources.go +++ b/engine/resources.go @@ -444,7 +444,7 @@ func (rS *ResourceService) cachedResourcesForEvent(evUUID string) (rs Resources) func (rS *ResourceService) matchingResourcesForEvent(ev *utils.CGREvent, usageTTL *time.Duration) (rs Resources, err error) { matchingResources := make(map[string]*Resource) rIDs, err := MatchingItemIDsForEvent(ev.Event, rS.stringIndexedFields, rS.prefixIndexedFields, - rS.dm, utils.CacheResourceFilterIndexes, ev.Tenant, rS.filterS.cfg.FilterSCfg().IndexedSelects) + rS.dm, utils.CacheResourceFilterIndexes, ev.Tenant, rS.filterS.cfg.ResourceSCfg().IndexedSelects) if err != nil { return nil, err } diff --git a/engine/resources_test.go b/engine/resources_test.go index 2d0459b8c..2a30203b0 100644 --- a/engine/resources_test.go +++ b/engine/resources_test.go @@ -685,7 +685,7 @@ func TestResourceUsageTTLCase4(t *testing.T) { } func TestResourceMatchWithIndexFalse(t *testing.T) { - resService.filterS.cfg.FilterSCfg().IndexedSelects = false + resService.filterS.cfg.ResourceSCfg().IndexedSelects = false mres, err := resService.matchingResourcesForEvent(resEvs[0], &timeDurationExample) if err != nil { t.Errorf("Error: %+v", err) diff --git a/engine/stats.go b/engine/stats.go index 388f49917..e2704dc39 100644 --- a/engine/stats.go +++ b/engine/stats.go @@ -152,7 +152,7 @@ func (sS *StatService) matchingStatQueuesForEvent(args *StatsArgsProcessEvent) ( sqIDs = args.StatIDs } else { mapIDs, err := MatchingItemIDsForEvent(args.Event, sS.stringIndexedFields, sS.prefixIndexedFields, - sS.dm, utils.CacheStatFilterIndexes, args.Tenant, sS.filterS.cfg.FilterSCfg().IndexedSelects) + sS.dm, utils.CacheStatFilterIndexes, args.Tenant, sS.filterS.cfg.StatSCfg().IndexedSelects) if err != nil { return nil, err } diff --git a/engine/stats_test.go b/engine/stats_test.go index d58418f3f..1faa7069a 100644 --- a/engine/stats_test.go +++ b/engine/stats_test.go @@ -308,7 +308,7 @@ func TestStatQueuesProcessEvent(t *testing.T) { } func TestStatQueuesMatchWithIndexFalse(t *testing.T) { - statService.filterS.cfg.FilterSCfg().IndexedSelects = false + statService.filterS.cfg.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 9211a6218..9711324a0 100644 --- a/engine/suppliers.go +++ b/engine/suppliers.go @@ -127,7 +127,7 @@ 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) (matchingLP *SupplierProfile, err error) { sPrflIDs, err := MatchingItemIDsForEvent(ev.Event, spS.stringIndexedFields, spS.prefixIndexedFields, - spS.dm, utils.CacheSupplierFilterIndexes, ev.Tenant, spS.filterS.cfg.FilterSCfg().IndexedSelects) + spS.dm, utils.CacheSupplierFilterIndexes, ev.Tenant, spS.filterS.cfg.SupplierSCfg().IndexedSelects) if err != nil { return nil, err } diff --git a/engine/suppliers_test.go b/engine/suppliers_test.go index 3bcdd8f1e..72e505a19 100644 --- a/engine/suppliers_test.go +++ b/engine/suppliers_test.go @@ -629,7 +629,7 @@ func TestSuppliersAsOptsGetSuppliersMaxCost(t *testing.T) { } func TestSuppliersMatchWithIndexFalse(t *testing.T) { - splService.filterS.cfg.FilterSCfg().IndexedSelects = false + splService.filterS.cfg.SupplierSCfg().IndexedSelects = false sprf, err := splService.matchingSupplierProfilesForEvent(&argsGetSuppliers[0].CGREvent) if err != nil { t.Errorf("Error: %+v", err) diff --git a/engine/thresholds.go b/engine/thresholds.go index 368a742d2..6c7e5de81 100644 --- a/engine/thresholds.go +++ b/engine/thresholds.go @@ -225,7 +225,7 @@ func (tS *ThresholdService) matchingThresholdsForEvent(args *ArgsProcessEvent) ( } else { tIDsMap, err := MatchingItemIDsForEvent(args.Event, tS.stringIndexedFields, tS.prefixIndexedFields, tS.dm, utils.CacheThresholdFilterIndexes, - args.Tenant, tS.filterS.cfg.FilterSCfg().IndexedSelects) + args.Tenant, tS.filterS.cfg.ThresholdSCfg().IndexedSelects) if err != nil { return nil, err }