From 944e87acd2a04faafe764eed16b893bddd22f0c6 Mon Sep 17 00:00:00 2001 From: TeoV Date: Tue, 28 Apr 2020 17:51:28 +0300 Subject: [PATCH] Rename from SupplierS to RouteS ( part2 ) --- config/config.go | 42 ++-- config/config_json.go | 10 +- config/config_json_test.go | 4 +- config/configsanity.go | 28 +-- config/libconfig_json.go | 6 +- config/routescfg.go | 133 +++++++++++++ ...supplierscfg_test.go => routescfg_test.go} | 4 +- config/sessionscfg.go | 28 +-- config/supplierscfg.go | 184 ------------------ engine/caches.go | 16 +- engine/datamanager.go | 82 ++++---- engine/filterindexer.go | 8 +- engine/libroutes.go | 35 ++-- engine/libtest.go | 8 +- engine/responder.go | 2 +- engine/route_highestcost.go | 30 +-- engine/route_leastcost.go | 28 +-- engine/route_load_distribution.go | 32 +-- engine/route_qos.go | 28 +-- engine/route_reas.go | 30 +-- engine/route_reds.go | 30 +-- engine/route_weight.go | 22 +-- engine/routes.go | 184 +++++++++--------- engine/routes_test.go | 14 +- engine/storage_csv.go | 38 ++-- engine/storage_interface.go | 10 +- engine/storage_internal_datadb.go | 52 +++-- engine/storage_internal_stordb.go | 16 +- engine/storage_mongo_datadb.go | 36 ++-- engine/storage_mongo_stordb.go | 22 +-- engine/storage_redis.go | 14 +- engine/storage_sql.go | 30 +-- engine/tpexporter.go | 8 +- engine/tpimporter_csv.go | 8 +- engine/tpreader.go | 58 +++--- engine/version.go | 4 +- servmanager/servmanager.go | 6 +- utils/apitpdata.go | 4 +- utils/cgrevent.go | 88 ++++++--- utils/consts.go | 68 ++++--- 40 files changed, 730 insertions(+), 720 deletions(-) create mode 100644 config/routescfg.go rename config/{supplierscfg_test.go => routescfg_test.go} (97%) delete mode 100644 config/supplierscfg.go diff --git a/config/config.go b/config/config.go index 584d9838e..b82c0470b 100755 --- a/config/config.go +++ b/config/config.go @@ -170,7 +170,7 @@ func NewDefaultCGRConfig() (cfg *CGRConfig, err error) { cfg.resourceSCfg = new(ResourceSConfig) cfg.statsCfg = new(StatSCfg) cfg.thresholdSCfg = new(ThresholdSCfg) - cfg.supplierSCfg = new(SupplierSCfg) + cfg.routeSCfg = new(RouteSCfg) cfg.sureTaxCfg = new(SureTaxCfg) cfg.dispatcherSCfg = new(DispatcherSCfg) cfg.loaderCgrCfg = new(LoaderCgrCfg) @@ -283,7 +283,7 @@ type CGRConfig struct { resourceSCfg *ResourceSConfig // ResourceS config statsCfg *StatSCfg // StatS config thresholdSCfg *ThresholdSCfg // ThresholdS config - supplierSCfg *SupplierSCfg // SupplierS config + routeSCfg *RouteSCfg // RouteS config sureTaxCfg *SureTaxCfg // SureTax config dispatcherSCfg *DispatcherSCfg // DispatcherS config loaderCgrCfg *LoaderCgrCfg // LoaderCgr config @@ -296,7 +296,7 @@ type CGRConfig struct { var posibleLoaderTypes = utils.NewStringSet([]string{utils.MetaAttributes, utils.MetaResources, utils.MetaFilters, utils.MetaStats, - utils.MetaSuppliers, utils.MetaThresholds, utils.MetaChargers, + utils.MetaRoutes, utils.MetaThresholds, utils.MetaChargers, utils.MetaDispatchers, utils.MetaDispatcherHosts}) var possibleReaderTypes = utils.NewStringSet([]string{utils.MetaFileCSV, @@ -333,7 +333,7 @@ func (cfg *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) (err error) { cfg.loadAsteriskAgentCfg, cfg.loadDiameterAgentCfg, cfg.loadRadiusAgentCfg, cfg.loadDNSAgentCfg, cfg.loadHttpAgentCfg, cfg.loadAttributeSCfg, cfg.loadChargerSCfg, cfg.loadResourceSCfg, cfg.loadStatSCfg, - cfg.loadThresholdSCfg, cfg.loadSupplierSCfg, cfg.loadLoaderSCfg, + cfg.loadThresholdSCfg, cfg.loadRouteSCfg, cfg.loadLoaderSCfg, cfg.loadMailerCfg, cfg.loadSureTaxCfg, cfg.loadDispatcherSCfg, cfg.loadLoaderCgrCfg, cfg.loadMigratorCgrCfg, cfg.loadTlsCgrCfg, cfg.loadAnalyzerCgrCfg, cfg.loadApierCfg, cfg.loadErsCfg} { @@ -613,13 +613,13 @@ func (cfg *CGRConfig) loadThresholdSCfg(jsnCfg *CgrJsonCfg) (err error) { return cfg.thresholdSCfg.loadFromJsonCfg(jsnThresholdSCfg) } -// loadSupplierSCfg loads the SupplierS section of the configuration -func (cfg *CGRConfig) loadSupplierSCfg(jsnCfg *CgrJsonCfg) (err error) { - var jsnSupplierSCfg *SupplierSJsonCfg - if jsnSupplierSCfg, err = jsnCfg.SupplierSJsonCfg(); err != nil { +// loadRouteSCfg loads the RouteS section of the configuration +func (cfg *CGRConfig) loadRouteSCfg(jsnCfg *CgrJsonCfg) (err error) { + var jsnRouteSCfg *RouteSJsonCfg + if jsnRouteSCfg, err = jsnCfg.RouteSJsonCfg(); err != nil { return } - return cfg.supplierSCfg.loadFromJsonCfg(jsnSupplierSCfg) + return cfg.routeSCfg.loadFromJsonCfg(jsnRouteSCfg) } // loadLoaderSCfg loads the LoaderS section of the configuration @@ -784,10 +784,10 @@ func (cfg *CGRConfig) ThresholdSCfg() *ThresholdSCfg { } // SupplierSCfg returns the config for SupplierS -func (cfg *CGRConfig) SupplierSCfg() *SupplierSCfg { - cfg.lks[SupplierSJson].Lock() - defer cfg.lks[SupplierSJson].Unlock() - return cfg.supplierSCfg +func (cfg *CGRConfig) RouteCfg() *RouteSCfg { + cfg.lks[RouteSJson].Lock() + defer cfg.lks[RouteSJson].Unlock() + return cfg.routeSCfg } // SessionSCfg returns the config for SessionS @@ -1033,8 +1033,8 @@ func (cfg *CGRConfig) V1GetConfigSection(args *StringWithArgDispatcher, reply *m jsonString = utils.ToJSON(cfg.StatSCfg()) case THRESHOLDS_JSON: jsonString = utils.ToJSON(cfg.ThresholdSCfg()) - case SupplierSJson: - jsonString = utils.ToJSON(cfg.SupplierSCfg()) + case RouteSJson: + jsonString = utils.ToJSON(cfg.RouteCfg()) case SURETAX_JSON: jsonString = utils.ToJSON(cfg.SureTaxCfg()) case DispatcherSJson: @@ -1150,7 +1150,7 @@ func (cfg *CGRConfig) getLoadFunctions() map[string]func(*CgrJsonCfg) error { RESOURCES_JSON: cfg.loadResourceSCfg, STATS_JSON: cfg.loadStatSCfg, THRESHOLDS_JSON: cfg.loadThresholdSCfg, - SupplierSJson: cfg.loadSupplierSCfg, + RouteSJson: cfg.loadRouteSCfg, LoaderJson: cfg.loadLoaderSCfg, MAILER_JSN: cfg.loadMailerCfg, SURETAX_JSON: cfg.loadSureTaxCfg, @@ -1352,7 +1352,7 @@ func (cfg *CGRConfig) reloadSections(sections ...string) (err error) { subsystemsThatNeedDataDB := utils.NewStringSet([]string{DATADB_JSN, SCHEDULER_JSN, RALS_JSN, CDRS_JSN, SessionSJson, ATTRIBUTE_JSN, ChargerSCfgJson, RESOURCES_JSON, STATS_JSON, THRESHOLDS_JSON, - SupplierSJson, LoaderJson, DispatcherSJson}) + RouteSJson, LoaderJson, DispatcherSJson}) subsystemsThatNeedStorDB := utils.NewStringSet([]string{STORDB_JSN, RALS_JSN, CDRS_JSN, ApierS}) needsDataDB := false needsStorDB := false @@ -1416,8 +1416,8 @@ func (cfg *CGRConfig) reloadSections(sections ...string) (err error) { cfg.rldChans[STATS_JSON] <- struct{}{} case THRESHOLDS_JSON: cfg.rldChans[THRESHOLDS_JSON] <- struct{}{} - case SupplierSJson: - cfg.rldChans[SupplierSJson] <- struct{}{} + case RouteSJson: + cfg.rldChans[RouteSJson] <- struct{}{} case LoaderJson: cfg.rldChans[LoaderJson] <- struct{}{} case DispatcherSJson: @@ -1481,8 +1481,8 @@ func (cfg *CGRConfig) AsMapInterface(separator string) map[string]interface{} { utils.ResourceSCfg: cfg.resourceSCfg.AsMapInterface(), utils.StatsCfg: cfg.statsCfg.AsMapInterface(), utils.ThresholdSCfg: cfg.thresholdSCfg.AsMapInterface(), - utils.SupplierSCfg: cfg.supplierSCfg.AsMapInterface(), - utils.SureTaxCfg: cfg.sureTaxCfg.AsMapInterface(separator), + utils.RouteSCfg: cfg.routeSCfg.AsMapInterface(), + utils.SureTaxCfg: cfg.sureTaxCfg.AsMapInterface(), utils.DispatcherSCfg: cfg.dispatcherSCfg.AsMapInterface(), utils.LoaderCgrCfg: cfg.loaderCgrCfg.AsMapInterface(), utils.MigratorCgrCfg: cfg.migratorCgrCfg.AsMapInterface(), diff --git a/config/config_json.go b/config/config_json.go index 1116b1583..da4fac823 100644 --- a/config/config_json.go +++ b/config/config_json.go @@ -45,7 +45,7 @@ const ( RESOURCES_JSON = "resources" STATS_JSON = "stats" THRESHOLDS_JSON = "thresholds" - SupplierSJson = "suppliers" + RouteSJson = "routes" LoaderJson = "loaders" MAILER_JSN = "mailer" SURETAX_JSON = "suretax" @@ -65,7 +65,7 @@ var ( sortedCfgSections = []string{GENERAL_JSN, RPCConnsJsonName, DATADB_JSN, STORDB_JSN, LISTEN_JSN, TlsCfgJson, HTTP_JSN, SCHEDULER_JSN, CACHE_JSN, FilterSjsn, RALS_JSN, CDRS_JSN, CDRE_JSN, ERsJson, SessionSJson, AsteriskAgentJSN, FreeSWITCHAgentJSN, KamailioAgentJSN, DA_JSN, RA_JSN, HttpAgentJson, DNSAgentJson, ATTRIBUTE_JSN, ChargerSCfgJson, RESOURCES_JSON, STATS_JSON, THRESHOLDS_JSON, - SupplierSJson, LoaderJson, MAILER_JSN, SURETAX_JSON, CgrLoaderCfgJson, CgrMigratorCfgJson, DispatcherSJson, AnalyzerCfgJson, ApierS} + RouteSJson, LoaderJson, MAILER_JSN, SURETAX_JSON, CgrLoaderCfgJson, CgrMigratorCfgJson, DispatcherSJson, AnalyzerCfgJson, ApierS} ) // Loads the json config out of io.Reader, eg other sources than file, maybe over http @@ -374,12 +374,12 @@ func (self CgrJsonCfg) ThresholdSJsonCfg() (*ThresholdSJsonCfg, error) { return cfg, nil } -func (self CgrJsonCfg) SupplierSJsonCfg() (*SupplierSJsonCfg, error) { - rawCfg, hasKey := self[SupplierSJson] +func (self CgrJsonCfg) RouteSJsonCfg() (*RouteSJsonCfg, error) { + rawCfg, hasKey := self[RouteSJson] if !hasKey { return nil, nil } - cfg := new(SupplierSJsonCfg) + cfg := new(RouteSJsonCfg) if err := json.Unmarshal(*rawCfg, cfg); err != nil { return nil, err } diff --git a/config/config_json_test.go b/config/config_json_test.go index 4ddffeb19..5e1dee05d 100755 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -1096,7 +1096,7 @@ func TestDfThresholdSJsonCfg(t *testing.T) { } func TestDfSupplierSJsonCfg(t *testing.T) { - eCfg := &SupplierSJsonCfg{ + eCfg := &RouteSJsonCfg{ Enabled: utils.BoolPointer(false), Indexed_selects: utils.BoolPointer(true), String_indexed_fields: nil, @@ -1108,7 +1108,7 @@ func TestDfSupplierSJsonCfg(t *testing.T) { Default_ratio: utils.IntPointer(1), Nested_fields: utils.BoolPointer(false), } - if cfg, err := dfCgrJsonCfg.SupplierSJsonCfg(); err != nil { + if cfg, err := dfCgrJsonCfg.RouteSJsonCfg(); err != nil { t.Error(err) } else if !reflect.DeepEqual(eCfg, cfg) { t.Errorf("expecting: %+v, received: %+v", utils.ToJSON(eCfg), utils.ToJSON(cfg)) diff --git a/config/configsanity.go b/config/configsanity.go index 0efb4290a..f6d39f313 100644 --- a/config/configsanity.go +++ b/config/configsanity.go @@ -166,9 +166,9 @@ func (cfg *CGRConfig) checkConfigSanity() error { return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.SessionS, connID) } } - for _, connID := range cfg.sessionSCfg.SupplSConns { - if strings.HasPrefix(connID, utils.MetaInternal) && !cfg.supplierSCfg.Enabled { - return fmt.Errorf("<%s> not enabled but requested by <%s> component.", utils.SupplierS, utils.SessionS) + for _, connID := range cfg.sessionSCfg.RouteSConns { + if strings.HasPrefix(connID, utils.MetaInternal) && !cfg.routeSCfg.Enabled { + return fmt.Errorf("<%s> not enabled but requested by <%s> component.", utils.RouteS, utils.SessionS) } if _, has := cfg.rpcConns[connID]; !has && !strings.HasPrefix(connID, utils.MetaInternal) { return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.SessionS, connID) @@ -351,30 +351,30 @@ func (cfg *CGRConfig) checkConfigSanity() error { } } } - // SupplierS checks - if cfg.supplierSCfg.Enabled { - for _, connID := range cfg.supplierSCfg.AttributeSConns { + // RouteS checks + if cfg.routeSCfg.Enabled { + for _, connID := range cfg.routeSCfg.AttributeSConns { if strings.HasPrefix(connID, utils.MetaInternal) && !cfg.attributeSCfg.Enabled { - return fmt.Errorf("<%s> not enabled but requested by <%s> component.", utils.AttributeS, utils.SupplierS) + return fmt.Errorf("<%s> not enabled but requested by <%s> component.", utils.AttributeS, utils.RouteS) } if _, has := cfg.rpcConns[connID]; !has && !strings.HasPrefix(connID, utils.MetaInternal) { - return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.SupplierS, connID) + return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.RouteS, connID) } } - for _, connID := range cfg.supplierSCfg.StatSConns { + for _, connID := range cfg.routeSCfg.StatSConns { if strings.HasPrefix(connID, utils.MetaInternal) && !cfg.statsCfg.Enabled { - return fmt.Errorf("<%s> not enabled but requested by <%s> component.", utils.StatService, utils.SupplierS) + return fmt.Errorf("<%s> not enabled but requested by <%s> component.", utils.StatService, utils.RouteS) } if _, has := cfg.rpcConns[connID]; !has && !strings.HasPrefix(connID, utils.MetaInternal) { - return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.SupplierS, connID) + return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.RouteS, connID) } } - for _, connID := range cfg.supplierSCfg.ResourceSConns { + for _, connID := range cfg.routeSCfg.ResourceSConns { if strings.HasPrefix(connID, utils.MetaInternal) && !cfg.resourceSCfg.Enabled { - return fmt.Errorf("<%s> not enabled but requested by <%s> component.", utils.ResourceS, utils.SupplierS) + return fmt.Errorf("<%s> not enabled but requested by <%s> component.", utils.ResourceS, utils.RouteS) } if _, has := cfg.rpcConns[connID]; !has && !strings.HasPrefix(connID, utils.MetaInternal) { - return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.SupplierS, connID) + return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.RouteS, connID) } } } diff --git a/config/libconfig_json.go b/config/libconfig_json.go index b2b6c1a59..eba8c9952 100755 --- a/config/libconfig_json.go +++ b/config/libconfig_json.go @@ -204,7 +204,7 @@ type SessionSJsonCfg struct { Resources_conns *[]string Thresholds_conns *[]string Stats_conns *[]string - Suppliers_conns *[]string + Routes_conns *[]string Cdrs_conns *[]string Replication_conns *[]string Attributes_conns *[]string @@ -428,8 +428,8 @@ type ThresholdSJsonCfg struct { Nested_fields *bool // applies when indexed fields is not defined } -// Supplier service config section -type SupplierSJsonCfg struct { +// Rounte service config section +type RouteSJsonCfg struct { Enabled *bool Indexed_selects *bool String_indexed_fields *[]string diff --git a/config/routescfg.go b/config/routescfg.go new file mode 100644 index 000000000..5e64d897e --- /dev/null +++ b/config/routescfg.go @@ -0,0 +1,133 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package config + +import ( + "strings" + + "github.com/cgrates/cgrates/utils" +) + +// RouteSCfg is the configuration of route service +type RouteSCfg struct { + Enabled bool + IndexedSelects bool + StringIndexedFields *[]string + PrefixIndexedFields *[]string + AttributeSConns []string + ResourceSConns []string + StatSConns []string + ResponderSConns []string + DefaultRatio int + NestedFields bool +} + +func (rts *RouteSCfg) loadFromJsonCfg(jsnCfg *RouteSJsonCfg) (err error) { + if jsnCfg == nil { + return nil + } + if jsnCfg.Enabled != nil { + rts.Enabled = *jsnCfg.Enabled + } + if jsnCfg.Indexed_selects != nil { + rts.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 { + sif[i] = fID + } + rts.StringIndexedFields = &sif + } + if jsnCfg.Prefix_indexed_fields != nil { + pif := make([]string, len(*jsnCfg.Prefix_indexed_fields)) + for i, fID := range *jsnCfg.Prefix_indexed_fields { + pif[i] = fID + } + rts.PrefixIndexedFields = &pif + } + if jsnCfg.Attributes_conns != nil { + rts.AttributeSConns = make([]string, len(*jsnCfg.Attributes_conns)) + for idx, conn := range *jsnCfg.Attributes_conns { + // if we have the connection internal we change the name so we can have internal rpc for each subsystem + if conn == utils.MetaInternal { + rts.AttributeSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes) + } else { + rts.AttributeSConns[idx] = conn + } + } + } + if jsnCfg.Resources_conns != nil { + rts.ResourceSConns = make([]string, len(*jsnCfg.Resources_conns)) + for idx, conn := range *jsnCfg.Resources_conns { + // if we have the connection internal we change the name so we can have internal rpc for each subsystem + if conn == utils.MetaInternal { + rts.ResourceSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaResources) + } else { + rts.ResourceSConns[idx] = conn + } + } + } + if jsnCfg.Stats_conns != nil { + rts.StatSConns = make([]string, len(*jsnCfg.Stats_conns)) + for idx, conn := range *jsnCfg.Stats_conns { + // if we have the connection internal we change the name so we can have internal rpc for each subsystem + if conn == utils.MetaInternal { + rts.StatSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaStats) + } else { + rts.StatSConns[idx] = conn + } + } + } + if jsnCfg.Rals_conns != nil { + rts.ResponderSConns = make([]string, len(*jsnCfg.Rals_conns)) + for idx, conn := range *jsnCfg.Rals_conns { + // if we have the connection internal we change the name so we can have internal rpc for each subsystem + if conn == utils.MetaInternal { + rts.ResponderSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaResponder) + } else { + rts.ResponderSConns[idx] = conn + } + } + } + if jsnCfg.Default_ratio != nil { + rts.DefaultRatio = *jsnCfg.Default_ratio + } + if jsnCfg.Nested_fields != nil { + rts.NestedFields = *jsnCfg.Nested_fields + } + return nil +} + +func (rts *RouteSCfg) AsMapInterface() map[string]interface{} { + + return map[string]interface{}{ + utils.EnabledCfg: rts.Enabled, + utils.IndexedSelectsCfg: rts.IndexedSelects, + utils.StringIndexedFieldsCfg: rts.StringIndexedFields, + utils.PrefixIndexedFieldsCfg: rts.PrefixIndexedFields, + utils.AttributeSConnsCfg: rts.AttributeSConns, + utils.ResourceSConnsCfg: rts.ResourceSConns, + utils.StatSConnsCfg: rts.StatSConns, + utils.RALsConnsCfg: rts.ResponderSConns, + utils.DefaultRatioCfg: rts.DefaultRatio, + utils.NestedFieldsCfg: rts.NestedFields, + } + +} diff --git a/config/supplierscfg_test.go b/config/routescfg_test.go similarity index 97% rename from config/supplierscfg_test.go rename to config/routescfg_test.go index 0736b17ca..4cde501b7 100644 --- a/config/supplierscfg_test.go +++ b/config/routescfg_test.go @@ -31,7 +31,7 @@ func TestSupplierSCfgloadFromJsonCfg(t *testing.T) { } else if !reflect.DeepEqual(supscfg, expected) { t.Errorf("Expected: %+v ,recived: %+v", expected, supscfg) } - if err := supscfg.loadFromJsonCfg(new(SupplierSJsonCfg)); err != nil { + if err := supscfg.loadFromJsonCfg(new(RouteSJsonCfg)); err != nil { t.Error(err) } else if !reflect.DeepEqual(supscfg, expected) { t.Errorf("Expected: %+v ,recived: %+v", expected, supscfg) @@ -56,7 +56,7 @@ func TestSupplierSCfgloadFromJsonCfg(t *testing.T) { } if jsnCfg, err := NewCgrJsonCfgFromBytes([]byte(cfgJSONStr)); err != nil { t.Error(err) - } else if jsnSupSCfg, err := jsnCfg.SupplierSJsonCfg(); err != nil { + } else if jsnSupSCfg, err := jsnCfg.RouteSJsonCfg(); err != nil { t.Error(err) } else if err = supscfg.loadFromJsonCfg(jsnSupSCfg); err != nil { t.Error(err) diff --git a/config/sessionscfg.go b/config/sessionscfg.go index 5ae68fed1..b0e2cf29e 100644 --- a/config/sessionscfg.go +++ b/config/sessionscfg.go @@ -81,7 +81,7 @@ type SessionSCfg struct { ResSConns []string ThreshSConns []string StatSConns []string - SupplSConns []string + RouteSConns []string AttrSConns []string CDRsConns []string ReplicationConns []string @@ -168,14 +168,14 @@ func (scfg *SessionSCfg) loadFromJsonCfg(jsnCfg *SessionSJsonCfg) (err error) { } } } - if jsnCfg.Suppliers_conns != nil { - scfg.SupplSConns = make([]string, len(*jsnCfg.Suppliers_conns)) - for idx, connID := range *jsnCfg.Suppliers_conns { + if jsnCfg.Routes_conns != nil { + scfg.RouteSConns = make([]string, len(*jsnCfg.Routes_conns)) + for idx, connID := range *jsnCfg.Routes_conns { // if we have the connection internal we change the name so we can have internal rpc for each subsystem if connID == utils.MetaInternal { - scfg.SupplSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaSuppliers) + scfg.RouteSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaRoutes) } else { - scfg.SupplSConns[idx] = connID + scfg.RouteSConns[idx] = connID } } } @@ -414,14 +414,14 @@ func (scfg *SessionSCfg) AsMapInterface() map[string]interface{} { return map[string]interface{}{ utils.EnabledCfg: scfg.Enabled, utils.ListenBijsonCfg: scfg.ListenBijson, - utils.ChargerSConnsCfg: chargerSConns, - utils.RALsConnsCfg: RALsConns, - utils.ResSConnsCfg: resSConns, - utils.ThreshSConnsCfg: threshSConns, - utils.StatSConnsCfg: statSConns, - utils.SupplSConnsCfg: supplSConns, - utils.AttrSConnsCfg: attrSConns, - utils.CDRsConnsCfg: CDRsConns, + utils.ChargerSConnsCfg: scfg.ChargerSConns, + utils.RALsConnsCfg: scfg.RALsConns, + utils.ResSConnsCfg: scfg.ResSConns, + utils.ThreshSConnsCfg: scfg.ThreshSConns, + utils.StatSConnsCfg: scfg.StatSConns, + utils.RouteSConnsCfg: scfg.RouteSConns, + utils.AttrSConnsCfg: scfg.AttrSConns, + utils.CDRsConnsCfg: scfg.CDRsConns, utils.ReplicationConnsCfg: scfg.ReplicationConns, utils.DebitIntervalCfg: debitInterval, utils.StoreSCostsCfg: scfg.StoreSCosts, diff --git a/config/supplierscfg.go b/config/supplierscfg.go deleted file mode 100644 index f3d375ad8..000000000 --- a/config/supplierscfg.go +++ /dev/null @@ -1,184 +0,0 @@ -/* -Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments -Copyright (C) ITsysCOM GmbH - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see -*/ - -package config - -import ( - "strings" - - "github.com/cgrates/cgrates/utils" -) - -// SupplierSCfg is the configuration of supplier service -type SupplierSCfg struct { - Enabled bool - IndexedSelects bool - StringIndexedFields *[]string - PrefixIndexedFields *[]string - AttributeSConns []string - ResourceSConns []string - StatSConns []string - ResponderSConns []string - DefaultRatio int - NestedFields bool -} - -func (spl *SupplierSCfg) loadFromJsonCfg(jsnCfg *SupplierSJsonCfg) (err error) { - if jsnCfg == nil { - return nil - } - 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 { - sif[i] = fID - } - spl.StringIndexedFields = &sif - } - if jsnCfg.Prefix_indexed_fields != nil { - pif := make([]string, len(*jsnCfg.Prefix_indexed_fields)) - for i, fID := range *jsnCfg.Prefix_indexed_fields { - pif[i] = fID - } - spl.PrefixIndexedFields = &pif - } - if jsnCfg.Attributes_conns != nil { - spl.AttributeSConns = make([]string, len(*jsnCfg.Attributes_conns)) - for idx, conn := range *jsnCfg.Attributes_conns { - // if we have the connection internal we change the name so we can have internal rpc for each subsystem - if conn == utils.MetaInternal { - spl.AttributeSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes) - } else { - spl.AttributeSConns[idx] = conn - } - } - } - if jsnCfg.Resources_conns != nil { - spl.ResourceSConns = make([]string, len(*jsnCfg.Resources_conns)) - for idx, conn := range *jsnCfg.Resources_conns { - // if we have the connection internal we change the name so we can have internal rpc for each subsystem - if conn == utils.MetaInternal { - spl.ResourceSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaResources) - } else { - spl.ResourceSConns[idx] = conn - } - } - } - if jsnCfg.Stats_conns != nil { - spl.StatSConns = make([]string, len(*jsnCfg.Stats_conns)) - for idx, conn := range *jsnCfg.Stats_conns { - // if we have the connection internal we change the name so we can have internal rpc for each subsystem - if conn == utils.MetaInternal { - spl.StatSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaStats) - } else { - spl.StatSConns[idx] = conn - } - } - } - if jsnCfg.Rals_conns != nil { - spl.ResponderSConns = make([]string, len(*jsnCfg.Rals_conns)) - for idx, conn := range *jsnCfg.Rals_conns { - // if we have the connection internal we change the name so we can have internal rpc for each subsystem - if conn == utils.MetaInternal { - spl.ResponderSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaResponder) - } else { - spl.ResponderSConns[idx] = conn - } - } - } - if jsnCfg.Default_ratio != nil { - spl.DefaultRatio = *jsnCfg.Default_ratio - } - if jsnCfg.Nested_fields != nil { - spl.NestedFields = *jsnCfg.Nested_fields - } - return nil -} - -func (spl *SupplierSCfg) AsMapInterface() map[string]interface{} { - stringIndexedFields := []string{} - if spl.StringIndexedFields != nil { - stringIndexedFields = make([]string, len(*spl.StringIndexedFields)) - for i, item := range *spl.StringIndexedFields { - stringIndexedFields[i] = item - } - } - prefixIndexedFields := []string{} - if spl.PrefixIndexedFields != nil { - prefixIndexedFields = make([]string, len(*spl.PrefixIndexedFields)) - for i, item := range *spl.PrefixIndexedFields { - prefixIndexedFields[i] = item - } - } - attributeSConns := make([]string, len(spl.AttributeSConns)) - for i, item := range spl.AttributeSConns { - buf := utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAttributes) - if item == buf { - attributeSConns[i] = strings.ReplaceAll(item, utils.CONCATENATED_KEY_SEP+utils.MetaAttributes, utils.EmptyString) - } else { - attributeSConns[i] = item - } - } - responderSConns := make([]string, len(spl.ResponderSConns)) - for i, item := range spl.ResponderSConns { - buf := utils.ConcatenatedKey(utils.MetaInternal, utils.MetaResponder) - - if item == buf { - responderSConns[i] = strings.ReplaceAll(item, utils.CONCATENATED_KEY_SEP+utils.MetaResponder, utils.EmptyString) - } else { - responderSConns[i] = item - } - } - resourceSConns := make([]string, len(spl.ResourceSConns)) - for i, item := range spl.ResourceSConns { - buf := utils.ConcatenatedKey(utils.MetaInternal, utils.MetaResources) - if item == buf { - resourceSConns[i] = strings.ReplaceAll(item, utils.CONCATENATED_KEY_SEP+utils.MetaResources, utils.EmptyString) - } else { - resourceSConns[i] = item - } - } - statSConns := make([]string, len(spl.StatSConns)) - for i, item := range spl.StatSConns { - buf := utils.ConcatenatedKey(utils.MetaInternal, utils.MetaStatS) - if item == buf { - statSConns[i] = strings.ReplaceAll(item, utils.CONCATENATED_KEY_SEP+utils.MetaStatS, utils.EmptyString) - } else { - statSConns[i] = item - } - } - - return map[string]interface{}{ - utils.EnabledCfg: spl.Enabled, - utils.IndexedSelectsCfg: spl.IndexedSelects, - utils.StringIndexedFieldsCfg: stringIndexedFields, - utils.PrefixIndexedFieldsCfg: prefixIndexedFields, - utils.AttributeSConnsCfg: attributeSConns, - utils.ResourceSConnsCfg: resourceSConns, - utils.StatSConnsCfg: statSConns, - utils.RALsConnsCfg: responderSConns, - utils.DefaultRatioCfg: spl.DefaultRatio, - utils.NestedFieldsCfg: spl.NestedFields, - } - -} diff --git a/engine/caches.go b/engine/caches.go index e933b7487..dd31b4588 100644 --- a/engine/caches.go +++ b/engine/caches.go @@ -50,8 +50,8 @@ func init() { gob.Register(new(StoredStatQueue)) gob.Register(new(StatQueueProfileWithArgDispatcher)) // Suppliers - gob.Register(new(SupplierProfile)) - gob.Register(new(SupplierProfileWithArgDispatcher)) + gob.Register(new(RouteProfile)) + gob.Register(new(RouteProfileWithArgDispatcher)) // Filters gob.Register(new(Filter)) gob.Register(new(FilterWithArgDispatcher)) @@ -388,8 +388,8 @@ func (chS *CacheS) V1ReloadCache(attrs utils.AttrReloadCacheWithArgDispatcher, r if err = chS.reloadCache(utils.FilterPrefix, attrs.FilterIDs); err != nil { return } - // SupplierProfile - if err = chS.reloadCache(utils.SupplierProfilePrefix, attrs.SupplierProfileIDs); err != nil { + // RouteProfiles + if err = chS.reloadCache(utils.RouteProfilePrefix, attrs.RouteProfileIDs); err != nil { return } // AttributeProfile @@ -456,7 +456,7 @@ func (chS *CacheS) V1LoadCache(args utils.AttrReloadCacheWithArgDispatcher, repl toStringSlice(args.ThresholdIDs), toStringSlice(args.ThresholdProfileIDs), toStringSlice(args.FilterIDs), - toStringSlice(args.SupplierProfileIDs), + toStringSlice(args.RouteProfileIDs), toStringSlice(args.AttributeProfileIDs), toStringSlice(args.ChargerProfileIDs), toStringSlice(args.DispatcherProfileIDs), @@ -514,7 +514,7 @@ func (chS *CacheS) V1FlushCache(args utils.AttrReloadCacheWithArgDispatcher, rep chS.flushCache(utils.CacheThresholds, args.ThresholdIDs) chS.flushCache(utils.CacheThresholdProfiles, args.ThresholdProfileIDs) chS.flushCache(utils.CacheFilters, args.FilterIDs) - chS.flushCache(utils.CacheSupplierProfiles, args.SupplierProfileIDs) + chS.flushCache(utils.CacheRouteProfiles, args.RouteProfileIDs) chS.flushCache(utils.CacheAttributeProfiles, args.AttributeProfileIDs) chS.flushCache(utils.CacheChargerProfiles, args.ChargerProfileIDs) chS.flushCache(utils.CacheDispatcherProfiles, args.DispatcherProfileIDs) @@ -586,8 +586,8 @@ func populateCacheLoadIDs(loadIDs map[string]int64, attrs utils.AttrReloadCache) if attrs.FilterIDs == nil || len(*attrs.FilterIDs) != 0 { cacheLoadIDs[utils.CacheFilters] = loadIDs[utils.CacheFilters] } - if attrs.SupplierProfileIDs == nil || len(*attrs.SupplierProfileIDs) != 0 { - cacheLoadIDs[utils.CacheSupplierProfiles] = loadIDs[utils.CacheSupplierProfiles] + if attrs.RouteProfileIDs == nil || len(*attrs.RouteProfileIDs) != 0 { + cacheLoadIDs[utils.CacheRouteProfiles] = loadIDs[utils.CacheRouteProfiles] } if attrs.AttributeProfileIDs == nil || len(*attrs.AttributeProfileIDs) != 0 { cacheLoadIDs[utils.CacheAttributeProfiles] = loadIDs[utils.CacheAttributeProfiles] diff --git a/engine/datamanager.go b/engine/datamanager.go index 12fe64028..8faa7182b 100644 --- a/engine/datamanager.go +++ b/engine/datamanager.go @@ -31,7 +31,7 @@ var ( utils.ResourceFilterIndexes: true, utils.StatFilterIndexes: true, utils.ThresholdFilterIndexes: true, - utils.SupplierFilterIndexes: true, + utils.RouteFilterIndexes: true, utils.ChargerFilterIndexes: true, utils.DispatcherFilterIndexes: true, } @@ -49,7 +49,7 @@ var ( utils.ThresholdPrefix: true, utils.ThresholdProfilePrefix: true, utils.FilterPrefix: true, - utils.SupplierProfilePrefix: true, + utils.RouteProfilePrefix: true, utils.AttributeProfilePrefix: true, utils.ChargerProfilePrefix: true, utils.DispatcherProfilePrefix: true, @@ -73,7 +73,7 @@ var ( utils.ThresholdPrefix: true, utils.ThresholdProfilePrefix: true, utils.FilterPrefix: true, - utils.SupplierProfilePrefix: true, + utils.RouteProfilePrefix: true, utils.AttributeProfilePrefix: true, utils.ChargerProfilePrefix: true, utils.DispatcherProfilePrefix: true, @@ -82,7 +82,7 @@ var ( utils.ResourceFilterIndexes: true, utils.StatFilterIndexes: true, utils.ThresholdFilterIndexes: true, - utils.SupplierFilterIndexes: true, + utils.RouteFilterIndexes: true, utils.ChargerFilterIndexes: true, utils.DispatcherFilterIndexes: true, } @@ -118,7 +118,7 @@ func (dm *DataManager) DataDB() DataDB { func (dm *DataManager) LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aaPlIDs, atrgIDs, sgIDs, rpIDs, resIDs, stqIDs, stqpIDs, thIDs, thpIDs, fltrIDs, - splPrflIDs, alsPrfIDs, cppIDs, dppIDs, dphIDs []string) (err error) { + rPrflIDs, alsPrfIDs, cppIDs, dppIDs, dphIDs []string) (err error) { if dm == nil { err = utils.ErrNoDatabaseConn return @@ -154,7 +154,7 @@ func (dm *DataManager) LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, utils.ThresholdPrefix: thIDs, utils.ThresholdProfilePrefix: thpIDs, utils.FilterPrefix: fltrIDs, - utils.SupplierProfilePrefix: splPrflIDs, + utils.RouteProfilePrefix: rPrflIDs, utils.AttributeProfilePrefix: alsPrfIDs, utils.ChargerProfilePrefix: cppIDs, utils.DispatcherProfilePrefix: dppIDs, @@ -279,9 +279,9 @@ func (dm *DataManager) CacheDataFromDB(prfx string, ids []string, mustBeCached b case utils.FilterPrefix: tntID := utils.NewTenantID(dataID) _, err = dm.GetFilter(tntID.Tenant, tntID.ID, false, true, utils.NonTransactional) - case utils.SupplierProfilePrefix: + case utils.RouteProfilePrefix: tntID := utils.NewTenantID(dataID) - _, err = dm.GetSupplierProfile(tntID.Tenant, tntID.ID, false, true, utils.NonTransactional) + _, err = dm.GetRouteProfile(tntID.Tenant, tntID.ID, false, true, utils.NonTransactional) case utils.AttributeProfilePrefix: tntID := utils.NewTenantID(dataID) _, err = dm.GetAttributeProfile(tntID.Tenant, tntID.ID, false, true, utils.NonTransactional) @@ -302,8 +302,8 @@ func (dm *DataManager) CacheDataFromDB(prfx string, ids []string, mustBeCached b err = dm.MatchFilterIndexFromKey(utils.CacheStatFilterIndexes, dataID) case utils.ThresholdFilterIndexes: err = dm.MatchFilterIndexFromKey(utils.CacheThresholdFilterIndexes, dataID) - case utils.SupplierFilterIndexes: - err = dm.MatchFilterIndexFromKey(utils.CacheSupplierFilterIndexes, dataID) + case utils.RouteFilterIndexes: + err = dm.MatchFilterIndexFromKey(utils.CacheRouteFilterIndexes, dataID) case utils.ChargerFilterIndexes: err = dm.MatchFilterIndexFromKey(utils.CacheChargerFilterIndexes, dataID) case utils.DispatcherFilterIndexes: @@ -2269,38 +2269,38 @@ func (dm *DataManager) MatchFilterIndex(cacheID, itemIDPrefix, return } -func (dm *DataManager) GetSupplierProfile(tenant, id string, cacheRead, cacheWrite bool, - transactionID string) (supp *SupplierProfile, err error) { +func (dm *DataManager) GetRouteProfile(tenant, id string, cacheRead, cacheWrite bool, + transactionID string) (rpp *RouteProfile, err error) { tntID := utils.ConcatenatedKey(tenant, id) if cacheRead { - if x, ok := Cache.Get(utils.CacheSupplierProfiles, tntID); ok { + if x, ok := Cache.Get(utils.CacheRouteProfiles, tntID); ok { if x == nil { return nil, utils.ErrNotFound } - return x.(*SupplierProfile), nil + return x.(*RouteProfile), nil } } if dm == nil { err = utils.ErrNoDatabaseConn return } - supp, err = dm.dataDB.GetSupplierProfileDrv(tenant, id) + rpp, err = dm.dataDB.GetRouteProfileDrv(tenant, id) if err != nil { - if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaSupplierProfiles]; err == utils.ErrNotFound && itm.Remote { + if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaRouteProfiles]; err == utils.ErrNotFound && itm.Remote { if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil, utils.ReplicatorSv1GetSupplierProfile, &utils.TenantIDWithArgDispatcher{ TenantID: &utils.TenantID{Tenant: tenant, ID: id}, ArgDispatcher: &utils.ArgDispatcher{ APIKey: utils.StringPointer(itm.APIKey), RouteID: utils.StringPointer(itm.RouteID), - }}, &supp); err == nil { - err = dm.dataDB.SetSupplierProfileDrv(supp) + }}, &rpp); err == nil { + err = dm.dataDB.SetRouteProfileDrv(rpp) } } if err != nil { err = utils.CastRPCErr(err) if err == utils.ErrNotFound && cacheWrite { - Cache.Set(utils.CacheSupplierProfiles, tntID, nil, nil, + Cache.Set(utils.CacheRouteProfiles, tntID, nil, nil, cacheCommit(transactionID), transactionID) } @@ -2308,54 +2308,54 @@ func (dm *DataManager) GetSupplierProfile(tenant, id string, cacheRead, cacheWri } } // populate cache will compute specific config parameters - if err = supp.Compile(); err != nil { + if err = rpp.Compile(); err != nil { return nil, err } if cacheWrite { - Cache.Set(utils.CacheSupplierProfiles, tntID, supp, nil, + Cache.Set(utils.CacheRouteProfiles, tntID, rpp, nil, cacheCommit(transactionID), transactionID) } return } -func (dm *DataManager) SetSupplierProfile(supp *SupplierProfile, withIndex bool) (err error) { +func (dm *DataManager) SetRouteProfile(rpp *RouteProfile, withIndex bool) (err error) { if dm == nil { err = utils.ErrNoDatabaseConn return } - oldSup, err := dm.GetSupplierProfile(supp.Tenant, supp.ID, true, false, utils.NonTransactional) + oldRpp, err := dm.GetRouteProfile(rpp.Tenant, rpp.ID, true, false, utils.NonTransactional) if err != nil && err != utils.ErrNotFound { return err } - if err = dm.DataDB().SetSupplierProfileDrv(supp); err != nil { + if err = dm.DataDB().SetRouteProfileDrv(rpp); err != nil { return err } if withIndex { - if oldSup != nil { + if oldRpp != nil { var needsRemove bool - for _, fltrID := range oldSup.FilterIDs { - if !utils.IsSliceMember(supp.FilterIDs, fltrID) { + for _, fltrID := range oldRpp.FilterIDs { + if !utils.IsSliceMember(rpp.FilterIDs, fltrID) { needsRemove = true } } if needsRemove { - if err = NewFilterIndexer(dm, utils.SupplierProfilePrefix, - supp.Tenant).RemoveItemFromIndex(supp.Tenant, supp.ID, oldSup.FilterIDs); err != nil { + if err = NewFilterIndexer(dm, utils.RouteProfilePrefix, + rpp.Tenant).RemoveItemFromIndex(rpp.Tenant, rpp.ID, oldRpp.FilterIDs); err != nil { return } } } - if err = createAndIndex(utils.SupplierProfilePrefix, supp.Tenant, - utils.EmptyString, supp.ID, supp.FilterIDs, dm); err != nil { + if err = createAndIndex(utils.RouteProfilePrefix, rpp.Tenant, + utils.EmptyString, rpp.ID, rpp.FilterIDs, dm); err != nil { return } } - if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaSupplierProfiles]; itm.Replicate { + if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaRouteProfiles]; itm.Replicate { var reply string if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RplConns, nil, utils.ReplicatorSv1SetSupplierProfile, - &SupplierProfileWithArgDispatcher{ - SupplierProfile: supp, + &RouteProfileWithArgDispatcher{ + RouteProfile: rpp, ArgDispatcher: &utils.ArgDispatcher{ APIKey: utils.StringPointer(itm.APIKey), RouteID: utils.StringPointer(itm.RouteID), @@ -2367,28 +2367,28 @@ func (dm *DataManager) SetSupplierProfile(supp *SupplierProfile, withIndex bool) return } -func (dm *DataManager) RemoveSupplierProfile(tenant, id, transactionID string, withIndex bool) (err error) { +func (dm *DataManager) RemoveRouteProfile(tenant, id, transactionID string, withIndex bool) (err error) { if dm == nil { err = utils.ErrNoDatabaseConn return } - oldSupp, err := dm.GetSupplierProfile(tenant, id, true, false, utils.NonTransactional) + oldRpp, err := dm.GetRouteProfile(tenant, id, true, false, utils.NonTransactional) if err != nil && err != utils.ErrNotFound { return err } - if err = dm.DataDB().RemoveSupplierProfileDrv(tenant, id); err != nil { + if err = dm.DataDB().RemoveRouteProfileDrv(tenant, id); err != nil { return } - if oldSupp == nil { + if oldRpp == nil { return utils.ErrNotFound } if withIndex { - if err = NewFilterIndexer(dm, utils.SupplierProfilePrefix, - tenant).RemoveItemFromIndex(tenant, id, oldSupp.FilterIDs); err != nil { + if err = NewFilterIndexer(dm, utils.RouteProfilePrefix, + tenant).RemoveItemFromIndex(tenant, id, oldRpp.FilterIDs); err != nil { return } } - if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaSupplierProfiles]; itm.Replicate { + if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaRouteProfiles]; itm.Replicate { var reply string dm.connMgr.Call(config.CgrConfig().DataDbCfg().RplConns, nil, utils.ReplicatorSv1RemoveSupplierProfile, diff --git a/engine/filterindexer.go b/engine/filterindexer.go index 641078bc9..cff82e48e 100644 --- a/engine/filterindexer.go +++ b/engine/filterindexer.go @@ -89,8 +89,8 @@ func (rfi *FilterIndexer) cacheRemItemType() { // ToDo: tune here by removing pe case utils.StatQueueProfilePrefix: Cache.Clear([]string{utils.CacheStatFilterIndexes}) - case utils.SupplierProfilePrefix: - Cache.Clear([]string{utils.CacheSupplierFilterIndexes}) + case utils.RouteProfilePrefix: + Cache.Clear([]string{utils.CacheRouteFilterIndexes}) case utils.AttributeProfilePrefix: Cache.Clear([]string{utils.CacheAttributeFilterIndexes}) @@ -183,8 +183,8 @@ func (rfi *FilterIndexer) RemoveItemFromIndex(tenant, itemID string, oldFilters filterIDs[i] = fltrID } } - case utils.SupplierProfilePrefix: - spp, err := rfi.dm.GetSupplierProfile(tenant, itemID, true, false, utils.NonTransactional) + case utils.RouteProfilePrefix: + spp, err := rfi.dm.GetRouteProfile(tenant, itemID, true, false, utils.NonTransactional) if err != nil && err != utils.ErrNotFound { return err } diff --git a/engine/libroutes.go b/engine/libroutes.go index 62d79fc4e..ec529e024 100644 --- a/engine/libroutes.go +++ b/engine/libroutes.go @@ -156,38 +156,33 @@ func (sSpls *SortedRoutes) SortLoadDistribution() { }) } -// Digest returns list of supplierIDs + parameters for easier outside access -// format suppl1:suppl1params,suppl2:suppl2params +// Digest returns list of routeIDs + parameters for easier outside access +// format route1:route1params,route2:route2params func (sSpls *SortedRoutes) Digest() string { return strings.Join(sSpls.RoutesWithParams(), utils.FIELDS_SEP) } func (sSpls *SortedRoutes) AsNavigableMap() (nm *config.NavigableMap) { mp := map[string]interface{}{ - "ProfileID": sSpls.ProfileID, - "Sorting": sSpls.Sorting, - "Count": sSpls.Count, + utils.ProfileID: sSpls.ProfileID, + utils.Sorting: sSpls.Sorting, + utils.Count: sSpls.Count, } - sm := make([]map[string]interface{}, len(sSpls.SortedRoutes)) + sr := make([]map[string]interface{}, len(sSpls.SortedRoutes)) for i, ss := range sSpls.SortedRoutes { - sm[i] = map[string]interface{}{ - "SupplierID": ss.RouteID, - "SupplierParameters": ss.RouteParameters, - "SortingData": ss.SortingData, + sr[i] = map[string]interface{}{ + utils.RouteID: ss.RouteID, + utils.RouteParameters: ss.RouteParameters, + utils.SortingData: ss.SortingData, } } - mp["SortedSuppliers"] = sm + mp[utils.SortedRoutes] = sr return config.NewNavigableMap(mp) } -type SupplierWithParams struct { - SupplierName string - SupplierParams string -} - -// SuppliersSorter is the interface which needs to be implemented by supplier sorters +// RoutesSorter is the interface which needs to be implemented by routes sorters type RoutesSorter interface { - SortRoutes(string, []*Route, *utils.CGREvent, *optsGetSuppliers) (*SortedRoutes, error) + SortRoutes(string, []*Route, *utils.CGREvent, *optsGetRoutes) (*SortedRoutes, error) } // NewRouteSortDispatcher constructs RouteSortDispatcher @@ -196,7 +191,7 @@ func NewRouteSortDispatcher(lcrS *RouteService) (rsd RouteSortDispatcher, err er rsd[utils.MetaWeight] = NewWeightSorter(lcrS) rsd[utils.MetaLC] = NewLeastCostSorter(lcrS) rsd[utils.MetaHC] = NewHighestCostSorter(lcrS) - rsd[utils.MetaQOS] = NewQOSSupplierSorter(lcrS) + rsd[utils.MetaQOS] = NewQOSRouteSorter(lcrS) rsd[utils.MetaReas] = NewResourceAscendetSorter(lcrS) rsd[utils.MetaReds] = NewResourceDescendentSorter(lcrS) rsd[utils.MetaLoad] = NewLoadDistributionSorter(lcrS) @@ -208,7 +203,7 @@ func NewRouteSortDispatcher(lcrS *RouteService) (rsd RouteSortDispatcher, err er type RouteSortDispatcher map[string]RoutesSorter func (ssd RouteSortDispatcher) SortSuppliers(prflID, strategy string, - suppls []*Route, suplEv *utils.CGREvent, extraOpts *optsGetSuppliers) (sortedRoutes *SortedRoutes, err error) { + suppls []*Route, suplEv *utils.CGREvent, extraOpts *optsGetRoutes) (sortedRoutes *SortedRoutes, err error) { sd, has := ssd[strategy] if !has { return nil, fmt.Errorf("unsupported sorting strategy: %s", strategy) diff --git a/engine/libtest.go b/engine/libtest.go index ab67ab9d5..55ea24c5c 100644 --- a/engine/libtest.go +++ b/engine/libtest.go @@ -581,11 +581,15 @@ func GetDefaultEmptyCacheStats() map[string]*ltcache.CacheStats { Items: 0, Groups: 0, }, - utils.CacheSupplierFilterIndexes: { + utils.CacheSTIR: { Items: 0, Groups: 0, }, - utils.CacheSupplierProfiles: { + utils.CacheRouteFilterIndexes: { + Items: 0, + Groups: 0, + }, + utils.CacheRouteProfiles: { Items: 0, Groups: 0, }, diff --git a/engine/responder.go b/engine/responder.go index 17cd21344..e5c27ce06 100644 --- a/engine/responder.go +++ b/engine/responder.go @@ -313,7 +313,7 @@ func (rs *Responder) GetMaxSessionTimeOnAccounts(arg *utils.GetMaxSessionTimeOnA reply *map[string]interface{}) (err error) { for _, anctID := range arg.AccountIDs { cd := &CallDescriptor{ - Category: utils.MetaSuppliers, + Category: utils.MetaRoutes, Tenant: arg.Tenant, Subject: arg.Subject, Account: anctID, diff --git a/engine/route_highestcost.go b/engine/route_highestcost.go index b447dabd4..7190bd95e 100755 --- a/engine/route_highestcost.go +++ b/engine/route_highestcost.go @@ -24,35 +24,35 @@ import ( "github.com/cgrates/cgrates/utils" ) -func NewHighestCostSorter(spS *SupplierService) *HightCostSorter { - return &HightCostSorter{spS: spS, +func NewHighestCostSorter(rS *RouteService) *HightCostSorter { + return &HightCostSorter{rS: rS, sorting: utils.MetaHC} } -// HightCostSorter sorts suppliers based on their cost +// HightCostSorter sorts routes based on their cost type HightCostSorter struct { sorting string - spS *SupplierService + rS *RouteService } -func (hcs *HightCostSorter) SortSuppliers(prflID string, suppls []*Supplier, - ev *utils.CGREvent, extraOpts *optsGetSuppliers) (sortedSuppls *SortedSuppliers, err error) { - sortedSuppls = &SortedSuppliers{ProfileID: prflID, - Sorting: hcs.sorting, - SortedSuppliers: make([]*SortedSupplier, 0)} - for _, s := range suppls { - if len(s.RatingPlanIDs) == 0 { +func (hcs *HightCostSorter) SortRoutes(prflID string, routes []*Route, + ev *utils.CGREvent, extraOpts *optsGetRoutes) (sortedRoutes *SortedRoutes, err error) { + sortedRoutes = &SortedRoutes{ProfileID: prflID, + Sorting: hcs.sorting, + SortedRoutes: make([]*SortedRoute, 0)} + for _, route := range routes { + if len(route.RatingPlanIDs) == 0 { utils.Logger.Warning( fmt.Sprintf("<%s> supplier: <%s> - empty RatingPlanIDs", - utils.SupplierS, s.ID)) + utils.RouteS, route.ID)) return nil, utils.NewErrMandatoryIeMissing("RatingPlanIDs") } - if srtSpl, pass, err := hcs.spS.populateSortingData(ev, s, extraOpts); err != nil { + if srtSpl, pass, err := hcs.rS.populateSortingData(ev, route, extraOpts); err != nil { return nil, err } else if pass && srtSpl != nil { - sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers, srtSpl) + sortedRoutes.SortedRoutes = append(sortedRoutes.SortedRoutes, srtSpl) } } - sortedSuppls.SortHighestCost() + sortedRoutes.SortHighestCost() return } diff --git a/engine/route_leastcost.go b/engine/route_leastcost.go index ca85e0005..6ede9aa58 100644 --- a/engine/route_leastcost.go +++ b/engine/route_leastcost.go @@ -24,35 +24,35 @@ import ( "github.com/cgrates/cgrates/utils" ) -func NewLeastCostSorter(spS *SupplierService) *LeastCostSorter { - return &LeastCostSorter{spS: spS, +func NewLeastCostSorter(rS *RouteService) *LeastCostSorter { + return &LeastCostSorter{rS: rS, sorting: utils.MetaLC} } -// LeastCostSorter sorts suppliers based on their cost +// LeastCostSorter sorts routes based on their cost type LeastCostSorter struct { sorting string - spS *SupplierService + rS *RouteService } -func (lcs *LeastCostSorter) SortSuppliers(prflID string, suppls []*Supplier, - ev *utils.CGREvent, extraOpts *optsGetSuppliers) (sortedSuppls *SortedSuppliers, err error) { - sortedSuppls = &SortedSuppliers{ProfileID: prflID, - Sorting: lcs.sorting, - SortedSuppliers: make([]*SortedSupplier, 0)} - for _, s := range suppls { +func (lcs *LeastCostSorter) SortRoutes(prflID string, routes []*Route, + ev *utils.CGREvent, extraOpts *optsGetRoutes) (sortedRoutes *SortedRoutes, err error) { + sortedRoutes = &SortedRoutes{ProfileID: prflID, + Sorting: lcs.sorting, + SortedRoutes: make([]*SortedRoute, 0)} + for _, s := range routes { if len(s.RatingPlanIDs) == 0 { utils.Logger.Warning( fmt.Sprintf("<%s> supplier: <%s> - empty RatingPlanIDs", - utils.SupplierS, s.ID)) + utils.RouteS, s.ID)) return nil, utils.NewErrMandatoryIeMissing("RatingPlanIDs") } - if srtSpl, pass, err := lcs.spS.populateSortingData(ev, s, extraOpts); err != nil { + if srtSpl, pass, err := lcs.rS.populateSortingData(ev, s, extraOpts); err != nil { return nil, err } else if pass && srtSpl != nil { - sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers, srtSpl) + sortedRoutes.SortedRoutes = append(sortedRoutes.SortedRoutes, srtSpl) } } - sortedSuppls.SortLeastCost() + sortedRoutes.SortLeastCost() return } diff --git a/engine/route_load_distribution.go b/engine/route_load_distribution.go index 6944ced35..2c67de7cd 100644 --- a/engine/route_load_distribution.go +++ b/engine/route_load_distribution.go @@ -24,44 +24,44 @@ import ( "github.com/cgrates/cgrates/utils" ) -func NewLoadDistributionSorter(spS *SupplierService) *LoadDistributionSorter { - return &LoadDistributionSorter{spS: spS, +func NewLoadDistributionSorter(rS *RouteService) *LoadDistributionSorter { + return &LoadDistributionSorter{rS: rS, sorting: utils.MetaLoad} } // ResourceAscendentSorter orders suppliers based on their Resource Usage type LoadDistributionSorter struct { sorting string - spS *SupplierService + rS *RouteService } -func (ws *LoadDistributionSorter) SortSuppliers(prflID string, - suppls []*Supplier, suplEv *utils.CGREvent, extraOpts *optsGetSuppliers) (sortedSuppls *SortedSuppliers, err error) { - sortedSuppls = &SortedSuppliers{ProfileID: prflID, - Sorting: ws.sorting, - SortedSuppliers: make([]*SortedSupplier, 0)} - for _, s := range suppls { +func (ws *LoadDistributionSorter) SortRoutes(prflID string, + routes []*Route, suplEv *utils.CGREvent, extraOpts *optsGetRoutes) (sortedRoutes *SortedRoutes, err error) { + sortedRoutes = &SortedRoutes{ProfileID: prflID, + Sorting: ws.sorting, + SortedRoutes: make([]*SortedRoute, 0)} + for _, route := range routes { // we should have at least 1 statID defined for counting CDR (a.k.a *sum:1) - if len(s.StatIDs) == 0 { + if len(route.StatIDs) == 0 { utils.Logger.Warning( fmt.Sprintf("<%s> supplier: <%s> - empty StatIDs", - utils.SupplierS, s.ID)) + utils.RouteS, route.ID)) return nil, utils.NewErrMandatoryIeMissing("StatIDs") } - if srtSpl, pass, err := ws.spS.populateSortingData(suplEv, s, extraOpts); err != nil { + if srtSpl, pass, err := ws.rS.populateSortingData(suplEv, route, extraOpts); err != nil { return nil, err } else if pass && srtSpl != nil { // Add the ratio in SortingData so we can used it later in SortLoadDistribution - floatRatio, err := utils.IfaceAsFloat64(s.cacheSupplier[utils.MetaRatio]) + floatRatio, err := utils.IfaceAsFloat64(route.cacheRoute[utils.MetaRatio]) if err != nil { utils.Logger.Warning( fmt.Sprintf("<%s> cannot convert ratio <%s> to float64 supplier: <%s>", - utils.SupplierS, s.cacheSupplier[utils.MetaRatio], s.ID)) + utils.RouteS, route.cacheRoute[utils.MetaRatio], route.ID)) } srtSpl.SortingData[utils.Ratio] = floatRatio - sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers, srtSpl) + sortedRoutes.SortedRoutes = append(sortedRoutes.SortedRoutes, srtSpl) } } - sortedSuppls.SortLoadDistribution() + sortedRoutes.SortLoadDistribution() return } diff --git a/engine/route_qos.go b/engine/route_qos.go index 6ef375d66..3ebba1a85 100755 --- a/engine/route_qos.go +++ b/engine/route_qos.go @@ -22,29 +22,29 @@ import ( "github.com/cgrates/cgrates/utils" ) -func NewQOSSupplierSorter(spS *SupplierService) *QOSSupplierSorter { - return &QOSSupplierSorter{spS: spS, +func NewQOSRouteSorter(rS *RouteService) *QOSRouteSorter { + return &QOSRouteSorter{rS: rS, sorting: utils.MetaQOS} } -// QOSSorter sorts suppliers based on stats -type QOSSupplierSorter struct { +// QOSSorter sorts route based on stats +type QOSRouteSorter struct { sorting string - spS *SupplierService + rS *RouteService } -func (qos *QOSSupplierSorter) SortSuppliers(prflID string, suppls []*Supplier, - ev *utils.CGREvent, extraOpts *optsGetSuppliers) (sortedSuppls *SortedSuppliers, err error) { - sortedSuppls = &SortedSuppliers{ProfileID: prflID, - Sorting: qos.sorting, - SortedSuppliers: make([]*SortedSupplier, 0)} - for _, s := range suppls { - if srtSpl, pass, err := qos.spS.populateSortingData(ev, s, extraOpts); err != nil { +func (qos *QOSRouteSorter) SortRoutes(prflID string, routes []*Route, + ev *utils.CGREvent, extraOpts *optsGetRoutes) (sortedRoutes *SortedRoutes, err error) { + sortedRoutes = &SortedRoutes{ProfileID: prflID, + Sorting: qos.sorting, + SortedRoutes: make([]*SortedRoute, 0)} + for _, route := range routes { + if srtSpl, pass, err := qos.rS.populateSortingData(ev, route, extraOpts); err != nil { return nil, err } else if pass && srtSpl != nil { - sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers, srtSpl) + sortedRoutes.SortedRoutes = append(sortedRoutes.SortedRoutes, srtSpl) } } - sortedSuppls.SortQOS(extraOpts.sortingParameters) + sortedRoutes.SortQOS(extraOpts.sortingParameters) return } diff --git a/engine/route_reas.go b/engine/route_reas.go index a51acfe8d..724c79072 100644 --- a/engine/route_reas.go +++ b/engine/route_reas.go @@ -24,35 +24,35 @@ import ( "github.com/cgrates/cgrates/utils" ) -func NewResourceAscendetSorter(spS *SupplierService) *ResourceAscendentSorter { - return &ResourceAscendentSorter{spS: spS, +func NewResourceAscendetSorter(rS *RouteService) *ResourceAscendentSorter { + return &ResourceAscendentSorter{rS: rS, sorting: utils.MetaReas} } -// ResourceAscendentSorter orders suppliers based on their Resource Usage +// ResourceAscendentSorter orders ascendent routes based on their Resource Usage type ResourceAscendentSorter struct { sorting string - spS *SupplierService + rS *RouteService } -func (ws *ResourceAscendentSorter) SortSuppliers(prflID string, - suppls []*Supplier, suplEv *utils.CGREvent, extraOpts *optsGetSuppliers) (sortedSuppls *SortedSuppliers, err error) { - sortedSuppls = &SortedSuppliers{ProfileID: prflID, - Sorting: ws.sorting, - SortedSuppliers: make([]*SortedSupplier, 0)} - for _, s := range suppls { - if len(s.ResourceIDs) == 0 { +func (ws *ResourceAscendentSorter) SortRoutes(prflID string, + routes []*Route, suplEv *utils.CGREvent, extraOpts *optsGetRoutes) (sortedRoutes *SortedRoutes, err error) { + sortedRoutes = &SortedRoutes{ProfileID: prflID, + Sorting: ws.sorting, + SortedRoutes: make([]*SortedRoute, 0)} + for _, route := range routes { + if len(route.ResourceIDs) == 0 { utils.Logger.Warning( fmt.Sprintf("<%s> supplier: <%s> - empty ResourceIDs", - utils.SupplierS, s.ID)) + utils.RouteS, route.ID)) return nil, utils.NewErrMandatoryIeMissing("ResourceIDs") } - if srtSpl, pass, err := ws.spS.populateSortingData(suplEv, s, extraOpts); err != nil { + if srtSpl, pass, err := ws.rS.populateSortingData(suplEv, route, extraOpts); err != nil { return nil, err } else if pass && srtSpl != nil { - sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers, srtSpl) + sortedRoutes.SortedRoutes = append(sortedRoutes.SortedRoutes, srtSpl) } } - sortedSuppls.SortResourceAscendent() + sortedRoutes.SortResourceAscendent() return } diff --git a/engine/route_reds.go b/engine/route_reds.go index 726df7839..a381d80ea 100644 --- a/engine/route_reds.go +++ b/engine/route_reds.go @@ -24,35 +24,35 @@ import ( "github.com/cgrates/cgrates/utils" ) -func NewResourceDescendentSorter(spS *SupplierService) *ResourceDescendentSorter { - return &ResourceDescendentSorter{spS: spS, +func NewResourceDescendentSorter(rS *RouteService) *ResourceDescendentSorter { + return &ResourceDescendentSorter{rS: rS, sorting: utils.MetaReds} } -// ResourceAscendentSorter orders suppliers based on their Resource Usage +// ResourceDescendentSorter orders suppliers based on their Resource Usage type ResourceDescendentSorter struct { sorting string - spS *SupplierService + rS *RouteService } -func (ws *ResourceDescendentSorter) SortSuppliers(prflID string, - suppls []*Supplier, suplEv *utils.CGREvent, extraOpts *optsGetSuppliers) (sortedSuppls *SortedSuppliers, err error) { - sortedSuppls = &SortedSuppliers{ProfileID: prflID, - Sorting: ws.sorting, - SortedSuppliers: make([]*SortedSupplier, 0)} - for _, s := range suppls { - if len(s.ResourceIDs) == 0 { +func (ws *ResourceDescendentSorter) SortRoutes(prflID string, + routes []*Route, suplEv *utils.CGREvent, extraOpts *optsGetRoutes) (sortedRoutes *SortedRoutes, err error) { + sortedRoutes = &SortedRoutes{ProfileID: prflID, + Sorting: ws.sorting, + SortedRoutes: make([]*SortedRoute, 0)} + for _, route := range routes { + if len(route.ResourceIDs) == 0 { utils.Logger.Warning( fmt.Sprintf("<%s> supplier: <%s> - empty ResourceIDs", - utils.SupplierS, s.ID)) + utils.RouteS, route.ID)) return nil, utils.NewErrMandatoryIeMissing("ResourceIDs") } - if srtSpl, pass, err := ws.spS.populateSortingData(suplEv, s, extraOpts); err != nil { + if srtSpl, pass, err := ws.rS.populateSortingData(suplEv, route, extraOpts); err != nil { return nil, err } else if pass && srtSpl != nil { - sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers, srtSpl) + sortedRoutes.SortedRoutes = append(sortedRoutes.SortedRoutes, srtSpl) } } - sortedSuppls.SortResourceDescendent() + sortedRoutes.SortResourceDescendent() return } diff --git a/engine/route_weight.go b/engine/route_weight.go index 9b0dbe392..9e36fc4b1 100755 --- a/engine/route_weight.go +++ b/engine/route_weight.go @@ -27,24 +27,24 @@ func NewWeightSorter(rS *RouteService) *WeightSorter { sorting: utils.MetaWeight} } -// WeightSorter orders suppliers based on their weight, no cost involved +// WeightSorter orders routes based on their weight, no cost involved type WeightSorter struct { sorting string rS *RouteService } -func (ws *WeightSorter) SortSuppliers(prflID string, - suppls []*Route, suplEv *utils.CGREvent, extraOpts *optsGetSuppliers) (sortedSuppls *SortedSuppliers, err error) { - sortedSuppls = &SortedSuppliers{ProfileID: prflID, - Sorting: ws.sorting, - SortedSuppliers: make([]*SortedSupplier, 0)} - for _, s := range suppls { - if srtSpl, pass, err := ws.rS.populateSortingData(suplEv, s, extraOpts); err != nil { +func (ws *WeightSorter) SortRoutes(prflID string, + routes []*Route, suplEv *utils.CGREvent, extraOpts *optsGetRoutes) (sortedRoutes *SortedRoutes, err error) { + sortedRoutes = &SortedRoutes{ProfileID: prflID, + Sorting: ws.sorting, + SortedRoutes: make([]*SortedRoute, 0)} + for _, route := range routes { + if srtRoute, pass, err := ws.rS.populateSortingData(suplEv, route, extraOpts); err != nil { return nil, err - } else if pass && srtSpl != nil { - sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers, srtSpl) + } else if pass && srtRoute != nil { + sortedRoutes.SortedRoutes = append(sortedRoutes.SortedRoutes, srtRoute) } } - sortedSuppls.SortWeight() + sortedRoutes.SortWeight() return } diff --git a/engine/routes.go b/engine/routes.go index 8ecf0733e..35c9f98a5 100644 --- a/engine/routes.go +++ b/engine/routes.go @@ -83,7 +83,7 @@ func (rp *RouteProfile) compileCacheParameters() error { route.cacheRoute = make(map[string]interface{}) if ratioSupplier, has := ratioMap[route.ID]; !has { // in case that ratio isn't defined for specific suppliers check for default if ratioDefault, has := ratioMap[utils.MetaDefault]; !has { // in case that *default ratio isn't defined take it from config - route.cacheRoute[utils.MetaRatio] = config.CgrConfig().SupplierSCfg().DefaultRatio + route.cacheRoute[utils.MetaRatio] = config.CgrConfig().RouteCfg().DefaultRatio } else { route.cacheRoute[utils.MetaRatio] = ratioDefault } @@ -133,7 +133,7 @@ type RouteService struct { dm *DataManager filterS *FilterS cgrcfg *config.CGRConfig - sorter SupplierSortDispatcher + sorter RouteSortDispatcher connMgr *ConnManager } @@ -152,64 +152,64 @@ func (rpS *RouteService) Shutdown() error { return nil } -// 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.cgrcfg.SupplierSCfg().IndexedSelects, - spS.cgrcfg.SupplierSCfg().NestedFields, +// matchingRouteProfilesForEvent returns ordered list of matching resources which are active by the time of the call +func (rpS *RouteService) matchingRouteProfilesForEvent(ev *utils.CGREvent, singleResult bool) (matchingRPrf []*RouteProfile, err error) { + rPrfIDs, err := MatchingItemIDsForEvent(ev.Event, + rpS.cgrcfg.RouteCfg().StringIndexedFields, + rpS.cgrcfg.RouteCfg().PrefixIndexedFields, + rpS.dm, utils.CacheRouteFilterIndexes, ev.Tenant, + rpS.cgrcfg.RouteCfg().IndexedSelects, + rpS.cgrcfg.RouteCfg().NestedFields, ) if err != nil { return nil, err } if singleResult { - matchingSLP = make([]*SupplierProfile, 1) + matchingRPrf = make([]*RouteProfile, 1) } evNm := config.NewNavigableMap(map[string]interface{}{utils.MetaReq: ev.Event}) - for lpID := range sPrflIDs { - splPrfl, err := spS.dm.GetSupplierProfile(ev.Tenant, lpID, true, true, utils.NonTransactional) + for lpID := range rPrfIDs { + rPrf, err := rpS.dm.GetRouteProfile(ev.Tenant, lpID, true, true, utils.NonTransactional) if err != nil { if err == utils.ErrNotFound { continue } return nil, err } - if splPrfl.ActivationInterval != nil && ev.Time != nil && - !splPrfl.ActivationInterval.IsActiveAtTime(*ev.Time) { // not active + if rPrf.ActivationInterval != nil && ev.Time != nil && + !rPrf.ActivationInterval.IsActiveAtTime(*ev.Time) { // not active continue } - if pass, err := spS.filterS.Pass(ev.Tenant, splPrfl.FilterIDs, + if pass, err := rpS.filterS.Pass(ev.Tenant, rPrf.FilterIDs, evNm); err != nil { return nil, err } else if !pass { continue } if singleResult { - if matchingSLP[0] == nil || matchingSLP[0].Weight < splPrfl.Weight { - matchingSLP[0] = splPrfl + if matchingRPrf[0] == nil || matchingRPrf[0].Weight < rPrf.Weight { + matchingRPrf[0] = rPrf } } else { - matchingSLP = append(matchingSLP, splPrfl) + matchingRPrf = append(matchingRPrf, rPrf) } } if singleResult { - if matchingSLP[0] == nil { + if matchingRPrf[0] == nil { return nil, utils.ErrNotFound } } else { - if len(matchingSLP) == 0 { + if len(matchingRPrf) == 0 { return nil, utils.ErrNotFound } - sort.Slice(matchingSLP, func(i, j int) bool { return matchingSLP[i].Weight > matchingSLP[j].Weight }) + sort.Slice(matchingRPrf, func(i, j int) bool { return matchingRPrf[i].Weight > matchingRPrf[j].Weight }) } return } // costForEvent will compute cost out of accounts and rating plans for event // returns map[string]interface{} with cost and relevant matching information inside -func (spS *SupplierService) costForEvent(ev *utils.CGREvent, +func (rpS *RouteService) costForEvent(ev *utils.CGREvent, acntIDs, rpIDs []string) (costData map[string]interface{}, err error) { if err = ev.CheckMandatoryFields([]string{utils.Account, utils.Destination, utils.SetupTime}); err != nil { @@ -229,7 +229,7 @@ func (spS *SupplierService) costForEvent(ev *utils.CGREvent, return } var sTime time.Time - if sTime, err = ev.FieldAsTime(utils.SetupTime, spS.cgrcfg.GeneralCfg().DefaultTimezone); err != nil { + if sTime, err = ev.FieldAsTime(utils.SetupTime, rpS.cgrcfg.GeneralCfg().DefaultTimezone); err != nil { return } var usage time.Duration @@ -241,7 +241,7 @@ func (spS *SupplierService) costForEvent(ev *utils.CGREvent, usage = time.Duration(1 * time.Minute) err = nil } - if err := spS.connMgr.Call(spS.cgrcfg.SupplierSCfg().ResponderSConns, nil, utils.ResponderGetMaxSessionTimeOnAccounts, + if err := rpS.connMgr.Call(rpS.cgrcfg.RouteCfg().ResponderSConns, nil, utils.ResponderGetMaxSessionTimeOnAccounts, &utils.GetMaxSessionTimeOnAccountsArgs{ Tenant: ev.Tenant, Subject: subj, @@ -252,7 +252,7 @@ func (spS *SupplierService) costForEvent(ev *utils.CGREvent, }, &costData); err != nil { return nil, err } - if err := spS.connMgr.Call(spS.cgrcfg.SupplierSCfg().ResponderSConns, nil, utils.ResponderGetCostOnRatingPlans, + if err := rpS.connMgr.Call(rpS.cgrcfg.RouteCfg().ResponderSConns, nil, utils.ResponderGetCostOnRatingPlans, &utils.GetCostOnRatingPlansArgs{ Tenant: ev.Tenant, Account: acnt, @@ -269,13 +269,13 @@ func (spS *SupplierService) costForEvent(ev *utils.CGREvent, // statMetrics will query a list of statIDs and return composed metric values // first metric found is always returned -func (spS *SupplierService) statMetrics(statIDs []string, tenant string) (stsMetric map[string]float64, err error) { +func (rpS *RouteService) statMetrics(statIDs []string, tenant string) (stsMetric map[string]float64, err error) { stsMetric = make(map[string]float64) provStsMetrics := make(map[string][]float64) - if len(spS.cgrcfg.SupplierSCfg().StatSConns) != 0 { + if len(rpS.cgrcfg.RouteCfg().StatSConns) != 0 { for _, statID := range statIDs { var metrics map[string]float64 - if err = spS.connMgr.Call(spS.cgrcfg.SupplierSCfg().StatSConns, nil, utils.StatSv1GetQueueFloatMetrics, + if err = rpS.connMgr.Call(rpS.cgrcfg.RouteCfg().StatSConns, nil, utils.StatSv1GetQueueFloatMetrics, &utils.TenantIDWithArgDispatcher{TenantID: &utils.TenantID{Tenant: tenant, ID: statID}}, &metrics); err != nil && err.Error() != utils.ErrNotFound.Error() { utils.Logger.Warning( @@ -299,15 +299,15 @@ func (spS *SupplierService) statMetrics(statIDs []string, tenant string) (stsMet // statMetricsForLoadDistribution will query a list of statIDs and return the sum of metrics // first metric found is always returned -func (spS *SupplierService) statMetricsForLoadDistribution(statIDs []string, tenant string) (result float64, err error) { +func (rpS *RouteService) statMetricsForLoadDistribution(statIDs []string, tenant string) (result float64, err error) { provStsMetrics := make(map[string][]float64) - if len(spS.cgrcfg.SupplierSCfg().StatSConns) != 0 { + if len(rpS.cgrcfg.RouteCfg().StatSConns) != 0 { for _, statID := range statIDs { // check if we get an ID in the following form (StatID:MetricID) statWithMetric := strings.Split(statID, utils.InInFieldSep) var metrics map[string]float64 - if err = spS.connMgr.Call( - spS.cgrcfg.SupplierSCfg().StatSConns, nil, + if err = rpS.connMgr.Call( + rpS.cgrcfg.RouteCfg().StatSConns, nil, utils.StatSv1GetQueueFloatMetrics, &utils.TenantIDWithArgDispatcher{ TenantID: &utils.TenantID{ @@ -322,7 +322,7 @@ func (spS *SupplierService) statMetricsForLoadDistribution(statIDs []string, ten // check if statQueue have metric defined if metricVal, has := metrics[statWithMetric[1]]; !has { return 0, fmt.Errorf("<%s> error: %s metric %s for statID: %s", - utils.SupplierS, utils.ErrNotFound, statWithMetric[1], statWithMetric[0]) + utils.RouteS, utils.ErrNotFound, statWithMetric[1], statWithMetric[0]) } else { provStsMetrics[statWithMetric[1]] = append(provStsMetrics[statWithMetric[1]], metricVal) } @@ -345,11 +345,11 @@ func (spS *SupplierService) statMetricsForLoadDistribution(statIDs []string, ten } // resourceUsage returns sum of all resource usages out of list -func (spS *SupplierService) resourceUsage(resIDs []string, tenant string) (tUsage float64, err error) { - if len(spS.cgrcfg.SupplierSCfg().ResourceSConns) != 0 { +func (rpS *RouteService) resourceUsage(resIDs []string, tenant string) (tUsage float64, err error) { + if len(rpS.cgrcfg.RouteCfg().ResourceSConns) != 0 { for _, resID := range resIDs { var res Resource - if err = spS.connMgr.Call(spS.cgrcfg.SupplierSCfg().ResourceSConns, nil, utils.ResourceSv1GetResource, + if err = rpS.connMgr.Call(rpS.cgrcfg.RouteCfg().ResourceSConns, nil, utils.ResourceSv1GetResource, &utils.TenantIDWithArgDispatcher{TenantID: &utils.TenantID{Tenant: tenant, ID: resID}}, &res); err != nil && err.Error() != utils.ErrNotFound.Error() { utils.Logger.Warning( fmt.Sprintf(" error: %s getting resource for ID : %s", err.Error(), resID)) @@ -361,31 +361,31 @@ func (spS *SupplierService) resourceUsage(resIDs []string, tenant string) (tUsag return } -func (spS *SupplierService) populateSortingData(ev *utils.CGREvent, spl *Supplier, - extraOpts *optsGetSuppliers) (srtSpl *SortedSupplier, pass bool, err error) { - sortedSpl := &SortedSupplier{ - SupplierID: spl.ID, +func (rpS *RouteService) populateSortingData(ev *utils.CGREvent, route *Route, + extraOpts *optsGetRoutes) (srtRoute *SortedRoute, pass bool, err error) { + sortedSpl := &SortedRoute{ + RouteID: route.ID, SortingData: map[string]interface{}{ - utils.Weight: spl.Weight, + utils.Weight: route.Weight, }, - SupplierParameters: spl.SupplierParameters, + RouteParameters: route.RouteParameters, } //calculate costData if we have fields - if len(spl.AccountIDs) != 0 || len(spl.RatingPlanIDs) != 0 { - costData, err := spS.costForEvent(ev, spl.AccountIDs, spl.RatingPlanIDs) + if len(route.AccountIDs) != 0 || len(route.RatingPlanIDs) != 0 { + costData, err := rpS.costForEvent(ev, route.AccountIDs, route.RatingPlanIDs) if err != nil { if extraOpts.ignoreErrors { utils.Logger.Warning( - fmt.Sprintf("<%s> ignoring supplier with ID: %s, err: %s", - utils.SupplierS, spl.ID, err.Error())) + fmt.Sprintf("<%s> ignoring route with ID: %s, err: %s", + utils.RouteS, route.ID, err.Error())) return nil, false, nil } else { return nil, false, err } } else if len(costData) == 0 { utils.Logger.Warning( - fmt.Sprintf("<%s> ignoring supplier with ID: %s, missing cost information", - utils.SupplierS, spl.ID)) + fmt.Sprintf("<%s> ignoring route with ID: %s, missing cost information", + utils.RouteS, route.ID)) } else { if extraOpts.maxCost != 0 && costData[utils.Cost].(float64) > extraOpts.maxCost { @@ -398,14 +398,14 @@ func (spS *SupplierService) populateSortingData(ev *utils.CGREvent, spl *Supplie } //calculate metrics //in case we have *load strategy we use statMetricsForLoadDistribution function to calculate the result - if len(spl.StatIDs) != 0 { + if len(route.StatIDs) != 0 { if extraOpts.sortingStragety == utils.MetaLoad { - metricSum, err := spS.statMetricsForLoadDistribution(spl.StatIDs, ev.Tenant) //create metric map for suppier + metricSum, err := rpS.statMetricsForLoadDistribution(route.StatIDs, ev.Tenant) //create metric map for route if err != nil { if extraOpts.ignoreErrors { utils.Logger.Warning( fmt.Sprintf("<%s> ignoring supplier with ID: %s, err: %s", - utils.SupplierS, spl.ID, err.Error())) + utils.RouteS, route.ID, err.Error())) return nil, false, nil } else { return nil, false, err @@ -413,12 +413,12 @@ func (spS *SupplierService) populateSortingData(ev *utils.CGREvent, spl *Supplie } sortedSpl.SortingData[utils.Load] = metricSum } else { - metricSupp, err := spS.statMetrics(spl.StatIDs, ev.Tenant) //create metric map for suppier + metricSupp, err := rpS.statMetrics(route.StatIDs, ev.Tenant) //create metric map for route if err != nil { if extraOpts.ignoreErrors { utils.Logger.Warning( fmt.Sprintf("<%s> ignoring supplier with ID: %s, err: %s", - utils.SupplierS, spl.ID, err.Error())) + utils.RouteS, route.ID, err.Error())) return nil, false, nil } else { return nil, false, err @@ -444,13 +444,13 @@ func (spS *SupplierService) populateSortingData(ev *utils.CGREvent, spl *Supplie } } //calculate resourceUsage - if len(spl.ResourceIDs) != 0 { - resTotalUsage, err := spS.resourceUsage(spl.ResourceIDs, ev.Tenant) + if len(route.ResourceIDs) != 0 { + resTotalUsage, err := rpS.resourceUsage(route.ResourceIDs, ev.Tenant) if err != nil { if extraOpts.ignoreErrors { utils.Logger.Warning( fmt.Sprintf("<%s> ignoring supplier with ID: %s, err: %s", - utils.SupplierS, spl.ID, err.Error())) + utils.RouteS, route.ID, err.Error())) return nil, false, nil } else { return nil, false, err @@ -459,14 +459,14 @@ func (spS *SupplierService) populateSortingData(ev *utils.CGREvent, spl *Supplie sortedSpl.SortingData[utils.ResourceUsage] = resTotalUsage } //filter the supplier - if len(spl.lazyCheckRules) != 0 { + if len(route.lazyCheckRules) != 0 { //construct the DP and pass it to filterS nM := config.NewNavigableMap(nil) nM.Set([]string{utils.MetaReq}, ev.Event, false, false) nM.Set([]string{utils.MetaVars}, sortedSpl.SortingData, false, false) - for _, rule := range spl.lazyCheckRules { // verify the rules remaining from PartialPass - if pass, err = rule.Pass(newDynamicDP(spS.cgrcfg, spS.connMgr, ev.Tenant, nM)); err != nil { + for _, rule := range route.lazyCheckRules { // verify the rules remaining from PartialPass + if pass, err = rule.Pass(newDynamicDP(rpS.cgrcfg, rpS.connMgr, ev.Tenant, nM)); err != nil { return nil, false, err } else if !pass { return nil, false, nil @@ -476,32 +476,32 @@ func (spS *SupplierService) populateSortingData(ev *utils.CGREvent, spl *Supplie return sortedSpl, true, nil } -// supliersForEvent will return the list of valid supplier IDs +// sortedRoutesForEvent will return the list of valid route IDs // for event based on filters and sorting algorithms -func (spS *SupplierService) sortedSuppliersForEvent(args *ArgsGetSuppliers) (sortedSuppls *SortedSuppliers, err error) { +func (rpS *RouteService) sortedRoutesForEvent(args *ArgsGetRoutes) (sortedRoutes *SortedRoutes, err error) { if _, has := args.CGREvent.Event[utils.Usage]; !has { args.CGREvent.Event[utils.Usage] = time.Duration(time.Minute) // make sure we have default set for Usage } - var splPrfls []*SupplierProfile - if splPrfls, err = spS.matchingSupplierProfilesForEvent(args.CGREvent, true); err != nil { + var rPrfs []*RouteProfile + if rPrfs, err = rpS.matchingRouteProfilesForEvent(args.CGREvent, true); err != nil { return } - splPrfl := splPrfls[0] + rPrfl := rPrfs[0] extraOpts, err := args.asOptsGetSuppliers() // convert suppliers arguments into internal options used to limit data if err != nil { return nil, err } - extraOpts.sortingParameters = splPrfl.SortingParameters // populate sortingParameters in extraOpts - extraOpts.sortingStragety = splPrfl.Sorting // populate sortinStrategy in extraOpts + extraOpts.sortingParameters = rPrfl.SortingParameters // populate sortingParameters in extraOpts + extraOpts.sortingStragety = rPrfl.Sorting // populate sortingStrategy in extraOpts //construct the DP and pass it to filterS nM := config.NewNavigableMap(nil) nM.Set([]string{utils.MetaReq}, args.CGREvent.Event, false, false) - supplNew := make([]*Supplier, 0) + routeNew := make([]*Route, 0) // apply filters for event - for _, suppl := range splPrfl.Suppliers { - pass, lazyCheckRules, err := spS.filterS.LazyPass(args.CGREvent.Tenant, suppl.FilterIDs, + for _, route := range rPrfl.Routes { + pass, lazyCheckRules, err := rpS.filterS.LazyPass(args.CGREvent.Tenant, route.FilterIDs, nM, []string{utils.DynamicDataPrefix + utils.MetaReq, utils.DynamicDataPrefix + utils.MetaAccounts, utils.DynamicDataPrefix + utils.MetaResources, utils.DynamicDataPrefix + utils.MetaStats}) if err != nil { @@ -509,30 +509,30 @@ func (spS *SupplierService) sortedSuppliersForEvent(args *ArgsGetSuppliers) (sor } else if !pass { continue } - suppl.lazyCheckRules = lazyCheckRules - supplNew = append(supplNew, suppl) + route.lazyCheckRules = lazyCheckRules + routeNew = append(routeNew, route) } - sortedSuppliers, err := spS.sorter.SortSuppliers(splPrfl.ID, splPrfl.Sorting, - supplNew, args.CGREvent, extraOpts) + sortedRoutes, err = rpS.sorter.SortSuppliers(rPrfl.ID, rPrfl.Sorting, + routeNew, args.CGREvent, extraOpts) if err != nil { return nil, err } if args.Paginator.Offset != nil { - if *args.Paginator.Offset <= len(sortedSuppliers.SortedSuppliers) { - sortedSuppliers.SortedSuppliers = sortedSuppliers.SortedSuppliers[*args.Paginator.Offset:] + if *args.Paginator.Offset <= len(sortedRoutes.SortedRoutes) { + sortedRoutes.SortedRoutes = sortedRoutes.SortedRoutes[*args.Paginator.Offset:] } } if args.Paginator.Limit != nil { - if *args.Paginator.Limit <= len(sortedSuppliers.SortedSuppliers) { - sortedSuppliers.SortedSuppliers = sortedSuppliers.SortedSuppliers[:*args.Paginator.Limit] + if *args.Paginator.Limit <= len(sortedRoutes.SortedRoutes) { + sortedRoutes.SortedRoutes = sortedRoutes.SortedRoutes[:*args.Paginator.Limit] } } - sortedSuppliers.Count = len(sortedSuppliers.SortedSuppliers) - return sortedSuppliers, nil + sortedRoutes.Count = len(sortedRoutes.SortedRoutes) + return } -type ArgsGetSuppliers struct { +type ArgsGetRoutes struct { IgnoreErrors bool MaxCost string // toDo: try with interface{} here Opts map[string]interface{} @@ -541,8 +541,8 @@ type ArgsGetSuppliers struct { *utils.ArgDispatcher } -func (args *ArgsGetSuppliers) asOptsGetSuppliers() (opts *optsGetSuppliers, err error) { - opts = &optsGetSuppliers{ignoreErrors: args.IgnoreErrors} +func (args *ArgsGetRoutes) asOptsGetSuppliers() (opts *optsGetRoutes, err error) { + opts = &optsGetRoutes{ignoreErrors: args.IgnoreErrors} if args.MaxCost == utils.MetaEventCost { // dynamic cost needs to be calculated from event if err = args.CGREvent.CheckMandatoryFields([]string{utils.Account, utils.Destination, utils.SetupTime, utils.Usage}); err != nil { @@ -567,7 +567,7 @@ func (args *ArgsGetSuppliers) asOptsGetSuppliers() (opts *optsGetSuppliers, err return } -type optsGetSuppliers struct { +type optsGetRoutes struct { ignoreErrors bool maxCost float64 sortingParameters []string //used for QOS strategy @@ -575,7 +575,7 @@ type optsGetSuppliers struct { } // V1GetSupplierProfilesForEvent returns the list of valid supplier IDs -func (spS *SupplierService) V1GetSuppliers(args *ArgsGetSuppliers, reply *SortedSuppliers) (err error) { +func (rpS *RouteService) V1GetSuppliers(args *ArgsGetRoutes, reply *SortedRoutes) (err error) { if args.CGREvent == nil { return utils.NewErrMandatoryIeMissing(utils.CGREventString) } @@ -584,16 +584,16 @@ func (spS *SupplierService) V1GetSuppliers(args *ArgsGetSuppliers, reply *Sorted } else if args.CGREvent.Event == nil { return utils.NewErrMandatoryIeMissing(utils.Event) } - if len(spS.cgrcfg.SupplierSCfg().AttributeSConns) != 0 { + if len(rpS.cgrcfg.RouteCfg().AttributeSConns) != 0 { attrArgs := &AttrArgsProcessEvent{ Context: utils.StringPointer(utils.FirstNonEmpty( - utils.IfaceAsString(args.Opts[utils.Context]), - utils.MetaSuppliers)), + utils.IfaceAsString(args.CGREvent.Event[utils.Context]), + utils.MetaRoutes)), CGREvent: args.CGREvent, ArgDispatcher: args.ArgDispatcher, } var rplyEv AttrSProcessEventReply - if err := spS.connMgr.Call(spS.cgrcfg.SupplierSCfg().AttributeSConns, nil, + if err := rpS.connMgr.Call(rpS.cgrcfg.RouteCfg().AttributeSConns, nil, utils.AttributeSv1ProcessEvent, attrArgs, &rplyEv); err == nil && len(rplyEv.AlteredFields) != 0 { args.CGREvent = rplyEv.CGREvent args.Opts = rplyEv.Opts @@ -601,7 +601,7 @@ func (spS *SupplierService) V1GetSuppliers(args *ArgsGetSuppliers, reply *Sorted return utils.NewErrAttributeS(err) } } - sSps, err := spS.sortedSuppliersForEvent(args) + sSps, err := rpS.sortedRoutesForEvent(args) if err != nil { if err != utils.ErrNotFound { err = utils.NewErrServerError(err) @@ -613,13 +613,13 @@ func (spS *SupplierService) V1GetSuppliers(args *ArgsGetSuppliers, reply *Sorted } // V1GetSupplierProfilesForEvent returns the list of valid supplier profiles -func (spS *SupplierService) V1GetSupplierProfilesForEvent(args *utils.CGREventWithArgDispatcher, reply *[]*SupplierProfile) (err error) { +func (rpS *RouteService) V1GetSupplierProfilesForEvent(args *utils.CGREventWithArgDispatcher, reply *[]*RouteProfile) (err error) { if missing := utils.MissingStructFields(args.CGREvent, []string{utils.Tenant, utils.ID}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } else if args.CGREvent.Event == nil { return utils.NewErrMandatoryIeMissing(utils.Event) } - sPs, err := spS.matchingSupplierProfilesForEvent(args.CGREvent, false) + sPs, err := rpS.matchingRouteProfilesForEvent(args.CGREvent, false) if err != nil { if err != utils.ErrNotFound { err = utils.NewErrServerError(err) diff --git a/engine/routes_test.go b/engine/routes_test.go index b6c27a6ab..9603f1456 100644 --- a/engine/routes_test.go +++ b/engine/routes_test.go @@ -376,8 +376,8 @@ func TestSuppliersCache(t *testing.T) { } } -func TestSuppliersmatchingSupplierProfilesForEvent(t *testing.T) { - sprf, err := splService.matchingSupplierProfilesForEvent(argsGetSuppliers[0].CGREvent, true) +func TestSuppliersmatchingRouteProfilesForEvent(t *testing.T) { + sprf, err := splService.matchingRouteProfilesForEvent(argsGetSuppliers[0].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -385,7 +385,7 @@ func TestSuppliersmatchingSupplierProfilesForEvent(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0]) } - sprf, err = splService.matchingSupplierProfilesForEvent(argsGetSuppliers[1].CGREvent, true) + sprf, err = splService.matchingRouteProfilesForEvent(argsGetSuppliers[1].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -393,7 +393,7 @@ func TestSuppliersmatchingSupplierProfilesForEvent(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0]) } - sprf, err = splService.matchingSupplierProfilesForEvent(argsGetSuppliers[2].CGREvent, true) + sprf, err = splService.matchingRouteProfilesForEvent(argsGetSuppliers[2].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -627,7 +627,7 @@ func TestSuppliersAsOptsGetSuppliersMaxCost(t *testing.T) { func TestSuppliersMatchWithIndexFalse(t *testing.T) { splService.cgrcfg.SupplierSCfg().IndexedSelects = false - sprf, err := splService.matchingSupplierProfilesForEvent(argsGetSuppliers[0].CGREvent, true) + sprf, err := splService.matchingRouteProfilesForEvent(argsGetSuppliers[0].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -635,7 +635,7 @@ func TestSuppliersMatchWithIndexFalse(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", sppTest[0], sprf[0]) } - sprf, err = splService.matchingSupplierProfilesForEvent(argsGetSuppliers[1].CGREvent, true) + sprf, err = splService.matchingRouteProfilesForEvent(argsGetSuppliers[1].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } @@ -643,7 +643,7 @@ func TestSuppliersMatchWithIndexFalse(t *testing.T) { t.Errorf("Expecting: %+v, received: %+v", sppTest[1], sprf[0]) } - sprf, err = splService.matchingSupplierProfilesForEvent(argsGetSuppliers[2].CGREvent, true) + sprf, err = splService.matchingRouteProfilesForEvent(argsGetSuppliers[2].CGREvent, true) if err != nil { t.Errorf("Error: %+v", err) } diff --git a/engine/storage_csv.go b/engine/storage_csv.go index 8536745a5..551f9a89c 100644 --- a/engine/storage_csv.go +++ b/engine/storage_csv.go @@ -60,7 +60,7 @@ type CSVStorage struct { statsFn []string thresholdsFn []string filterFn []string - suppProfilesFn []string + routeProfilesFn []string attributeProfilesFn []string chargerProfilesFn []string dispatcherProfilesFn []string @@ -73,7 +73,7 @@ func NewCSVStorage(sep rune, destinationratetimingsFn, ratingprofilesFn, sharedgroupsFn, actionsFn, actiontimingsFn, actiontriggersFn, accountactionsFn, resProfilesFn, statsFn, thresholdsFn, - filterFn, suppProfilesFn, attributeProfilesFn, + filterFn, routeProfilesFn, attributeProfilesFn, chargerProfilesFn, dispatcherProfilesFn, dispatcherHostsFn []string) *CSVStorage { return &CSVStorage{ sep: sep, @@ -93,7 +93,7 @@ func NewCSVStorage(sep rune, statsFn: statsFn, thresholdsFn: thresholdsFn, filterFn: filterFn, - suppProfilesFn: suppProfilesFn, + routeProfilesFn: routeProfilesFn, attributeProfilesFn: attributeProfilesFn, chargerProfilesFn: chargerProfilesFn, dispatcherProfilesFn: dispatcherProfilesFn, @@ -122,7 +122,7 @@ func NewFileCSVStorage(sep rune, dataPath string) *CSVStorage { statsPaths := appendName(allFoldersPath, utils.StatsCsv) thresholdsPaths := appendName(allFoldersPath, utils.ThresholdsCsv) filtersPaths := appendName(allFoldersPath, utils.FiltersCsv) - suppliersPaths := appendName(allFoldersPath, utils.SuppliersCsv) + routesPaths := appendName(allFoldersPath, utils.RoutesCsv) attributesPaths := appendName(allFoldersPath, utils.AttributesCsv) chargersPaths := appendName(allFoldersPath, utils.ChargersCsv) dispatcherprofilesPaths := appendName(allFoldersPath, utils.DispatcherProfilesCsv) @@ -143,7 +143,7 @@ func NewFileCSVStorage(sep rune, dataPath string) *CSVStorage { statsPaths, thresholdsPaths, filtersPaths, - suppliersPaths, + routesPaths, attributesPaths, chargersPaths, dispatcherprofilesPaths, @@ -157,7 +157,7 @@ func NewStringCSVStorage(sep rune, destinationratetimingsFn, ratingprofilesFn, sharedgroupsFn, actionsFn, actiontimingsFn, actiontriggersFn, accountactionsFn, resProfilesFn, statsFn, - thresholdsFn, filterFn, suppProfilesFn, + thresholdsFn, filterFn, routeProfilesFn, attributeProfilesFn, chargerProfilesFn, dispatcherProfilesFn, dispatcherHostsFn string) *CSVStorage { c := NewCSVStorage(sep, []string{destinationsFn}, []string{timingsFn}, @@ -165,7 +165,7 @@ func NewStringCSVStorage(sep rune, []string{ratingprofilesFn}, []string{sharedgroupsFn}, []string{actionsFn}, []string{actiontimingsFn}, []string{actiontriggersFn}, []string{accountactionsFn}, []string{resProfilesFn}, []string{statsFn}, []string{thresholdsFn}, []string{filterFn}, - []string{suppProfilesFn}, []string{attributeProfilesFn}, []string{chargerProfilesFn}, + []string{routeProfilesFn}, []string{attributeProfilesFn}, []string{chargerProfilesFn}, []string{dispatcherProfilesFn}, []string{dispatcherHostsFn}) c.generator = NewCsvString return c @@ -203,7 +203,7 @@ func NewGoogleCSVStorage(sep rune, spreadsheetID string) (*CSVStorage, error) { getIfExist(utils.Stats), getIfExist(utils.Thresholds), getIfExist(utils.Filters), - getIfExist(utils.Suppliers), + getIfExist(utils.Routes), getIfExist(utils.Attributes), getIfExist(utils.Chargers), getIfExist(utils.DispatcherProfiles), @@ -234,7 +234,7 @@ func NewURLCSVStorage(sep rune, dataPath string) *CSVStorage { var statsPaths []string var thresholdsPaths []string var filtersPaths []string - var suppliersPaths []string + var routesPaths []string var attributesPaths []string var chargersPaths []string var dispatcherprofilesPaths []string @@ -257,7 +257,7 @@ func NewURLCSVStorage(sep rune, dataPath string) *CSVStorage { statsPaths = append(statsPaths, joinURL(baseURL, utils.StatsCsv)) thresholdsPaths = append(thresholdsPaths, joinURL(baseURL, utils.ThresholdsCsv)) filtersPaths = append(filtersPaths, joinURL(baseURL, utils.FiltersCsv)) - suppliersPaths = append(suppliersPaths, joinURL(baseURL, utils.SuppliersCsv)) + routesPaths = append(routesPaths, joinURL(baseURL, utils.RoutesCsv)) attributesPaths = append(attributesPaths, joinURL(baseURL, utils.AttributesCsv)) chargersPaths = append(chargersPaths, joinURL(baseURL, utils.ChargersCsv)) dispatcherprofilesPaths = append(dispatcherprofilesPaths, joinURL(baseURL, utils.DispatcherProfilesCsv)) @@ -295,8 +295,8 @@ func NewURLCSVStorage(sep rune, dataPath string) *CSVStorage { thresholdsPaths = append(thresholdsPaths, baseURL) case strings.HasSuffix(baseURL, utils.FiltersCsv): filtersPaths = append(filtersPaths, baseURL) - case strings.HasSuffix(baseURL, utils.SuppliersCsv): - suppliersPaths = append(suppliersPaths, baseURL) + case strings.HasSuffix(baseURL, utils.RoutesCsv): + routesPaths = append(routesPaths, baseURL) case strings.HasSuffix(baseURL, utils.AttributesCsv): attributesPaths = append(attributesPaths, baseURL) case strings.HasSuffix(baseURL, utils.ChargersCsv): @@ -324,7 +324,7 @@ func NewURLCSVStorage(sep rune, dataPath string) *CSVStorage { statsPaths, thresholdsPaths, filtersPaths, - suppliersPaths, + routesPaths, attributesPaths, chargersPaths, dispatcherprofilesPaths, @@ -583,16 +583,16 @@ func (csvs *CSVStorage) GetTPFilters(tpid, tenant, id string) ([]*utils.TPFilter return tpFilter.AsTPFilter(), nil } -func (csvs *CSVStorage) GetTPSuppliers(tpid, tenant, id string) ([]*utils.TPSupplierProfile, error) { - var tpSPPs TpSuppliers - if err := csvs.proccesData(TpSupplier{}, csvs.suppProfilesFn, func(tp interface{}) { - suppProfile := tp.(TpSupplier) +func (csvs *CSVStorage) GetTPRoutes(tpid, tenant, id string) ([]*utils.TPRouteProfile, error) { + var tpRoutes TPRoutes + if err := csvs.proccesData(TpRoute{}, csvs.routeProfilesFn, func(tp interface{}) { + suppProfile := tp.(TpRoute) suppProfile.Tpid = tpid - tpSPPs = append(tpSPPs, &suppProfile) + tpRoutes = append(tpRoutes, &suppProfile) }); err != nil { return nil, err } - return tpSPPs.AsTPSuppliers(), nil + return tpRoutes.AsTPRouteProfile(), nil } func (csvs *CSVStorage) GetTPAttributes(tpid, tenant, id string) ([]*utils.TPAttributeProfile, error) { diff --git a/engine/storage_interface.go b/engine/storage_interface.go index 701543c29..60506770a 100644 --- a/engine/storage_interface.go +++ b/engine/storage_interface.go @@ -115,9 +115,9 @@ type DataDB interface { GetFilterDrv(string, string) (*Filter, error) SetFilterDrv(*Filter) error RemoveFilterDrv(string, string) error - GetSupplierProfileDrv(string, string) (*SupplierProfile, error) - SetSupplierProfileDrv(*SupplierProfile) error - RemoveSupplierProfileDrv(string, string) error + GetRouteProfileDrv(string, string) (*RouteProfile, error) + SetRouteProfileDrv(*RouteProfile) error + RemoveRouteProfileDrv(string, string) error GetAttributeProfileDrv(string, string) (*AttributeProfile, error) SetAttributeProfileDrv(*AttributeProfile) error RemoveAttributeProfileDrv(string, string) error @@ -177,7 +177,7 @@ type LoadReader interface { GetTPStats(string, string, string) ([]*utils.TPStatProfile, error) GetTPThresholds(string, string, string) ([]*utils.TPThresholdProfile, error) GetTPFilters(string, string, string) ([]*utils.TPFilterProfile, error) - GetTPSuppliers(string, string, string) ([]*utils.TPSupplierProfile, error) + GetTPRoutes(string, string, string) ([]*utils.TPRouteProfile, error) GetTPAttributes(string, string, string) ([]*utils.TPAttributeProfile, error) GetTPChargers(string, string, string) ([]*utils.TPChargerProfile, error) GetTPDispatcherProfiles(string, string, string) ([]*utils.TPDispatcherProfile, error) @@ -201,7 +201,7 @@ type LoadWriter interface { SetTPStats([]*utils.TPStatProfile) error SetTPThresholds([]*utils.TPThresholdProfile) error SetTPFilters([]*utils.TPFilterProfile) error - SetTPSuppliers([]*utils.TPSupplierProfile) error + SetTPRoutes([]*utils.TPRouteProfile) error SetTPAttributes([]*utils.TPAttributeProfile) error SetTPChargers([]*utils.TPChargerProfile) error SetTPDispatcherProfiles([]*utils.TPDispatcherProfile) error diff --git a/engine/storage_internal_datadb.go b/engine/storage_internal_datadb.go index a6a67ccb6..3860494a6 100644 --- a/engine/storage_internal_datadb.go +++ b/engine/storage_internal_datadb.go @@ -140,15 +140,15 @@ func newInternalDBCfg(itemsCacheCfg map[string]*config.ItemOpt, isDataDB bool) m TTL: itemsCacheCfg[utils.CacheThresholds].TTL, StaticTTL: itemsCacheCfg[utils.CacheThresholds].StaticTTL, }, - utils.CacheSupplierFilterIndexes: <cache.CacheConfig{ + utils.CacheRouteFilterIndexes: <cache.CacheConfig{ MaxItems: itemsCacheCfg[utils.MetaFilterIndexes].Limit, TTL: itemsCacheCfg[utils.MetaFilterIndexes].TTL, StaticTTL: itemsCacheCfg[utils.MetaFilterIndexes].StaticTTL, }, - utils.CacheSupplierProfiles: <cache.CacheConfig{ - MaxItems: itemsCacheCfg[utils.CacheSupplierProfiles].Limit, - TTL: itemsCacheCfg[utils.CacheSupplierProfiles].TTL, - StaticTTL: itemsCacheCfg[utils.CacheSupplierProfiles].StaticTTL, + utils.CacheRouteProfiles: <cache.CacheConfig{ + MaxItems: itemsCacheCfg[utils.CacheRouteProfiles].Limit, + TTL: itemsCacheCfg[utils.CacheRouteProfiles].TTL, + StaticTTL: itemsCacheCfg[utils.CacheRouteProfiles].StaticTTL, }, utils.CacheChargerFilterIndexes: <cache.CacheConfig{ MaxItems: itemsCacheCfg[utils.MetaFilterIndexes].Limit, @@ -278,10 +278,10 @@ func newInternalDBCfg(itemsCacheCfg map[string]*config.ItemOpt, isDataDB bool) m TTL: itemsCacheCfg[utils.TBLTPActionPlans].TTL, StaticTTL: itemsCacheCfg[utils.TBLTPActionPlans].StaticTTL, }, - utils.TBLTPSuppliers: <cache.CacheConfig{ - MaxItems: itemsCacheCfg[utils.TBLTPSuppliers].Limit, - TTL: itemsCacheCfg[utils.TBLTPSuppliers].TTL, - StaticTTL: itemsCacheCfg[utils.TBLTPSuppliers].StaticTTL, + utils.TBLTPRoutes: <cache.CacheConfig{ + MaxItems: itemsCacheCfg[utils.TBLTPRoutes].Limit, + TTL: itemsCacheCfg[utils.TBLTPRoutes].TTL, + StaticTTL: itemsCacheCfg[utils.TBLTPRoutes].StaticTTL, }, utils.TBLTPAttributes: <cache.CacheConfig{ MaxItems: itemsCacheCfg[utils.TBLTPAttributes].Limit, @@ -516,7 +516,7 @@ func (iDB *InternalDB) HasDataDrv(category, subject, tenant string) (bool, error return iDB.db.HasItem(utils.CachePrefixToInstance[category], subject), nil case utils.ResourcesPrefix, utils.ResourceProfilesPrefix, utils.StatQueuePrefix, utils.StatQueueProfilePrefix, utils.ThresholdPrefix, utils.ThresholdProfilePrefix, - utils.FilterPrefix, utils.SupplierProfilePrefix, utils.AttributeProfilePrefix, + utils.FilterPrefix, utils.RouteProfilePrefix, utils.AttributeProfilePrefix, utils.ChargerProfilePrefix, utils.DispatcherProfilePrefix, utils.DispatcherHostPrefix: return iDB.db.HasItem(utils.CachePrefixToInstance[category], utils.ConcatenatedKey(tenant, subject)), nil } @@ -1258,24 +1258,26 @@ func (iDB *InternalDB) RemoveFilterDrv(tenant, id string) (err error) { return } -func (iDB *InternalDB) GetSupplierProfileDrv(tenant, id string) (spp *SupplierProfile, err error) { - x, ok := iDB.db.Get(utils.CacheSupplierProfiles, utils.ConcatenatedKey(tenant, id)) +func (iDB *InternalDB) GetRouteProfileDrv(tenant, id string) (spp *RouteProfile, err error) { + x, ok := iDB.db.Get(utils.CacheRouteProfiles, utils.ConcatenatedKey(tenant, id)) if !ok || x == nil { return nil, utils.ErrNotFound } - return x.(*SupplierProfile), nil + return x.(*RouteProfile), nil +} -} -func (iDB *InternalDB) SetSupplierProfileDrv(spp *SupplierProfile) (err error) { - iDB.db.Set(utils.CacheSupplierProfiles, spp.TenantID(), spp, nil, +func (iDB *InternalDB) SetRouteProfileDrv(spp *RouteProfile) (err error) { + iDB.db.Set(utils.CacheRouteProfiles, spp.TenantID(), spp, nil, cacheCommit(utils.NonTransactional), utils.NonTransactional) return } -func (iDB *InternalDB) RemoveSupplierProfileDrv(tenant, id string) (err error) { - iDB.db.Remove(utils.CacheSupplierProfiles, utils.ConcatenatedKey(tenant, id), + +func (iDB *InternalDB) RemoveRouteProfileDrv(tenant, id string) (err error) { + iDB.db.Remove(utils.CacheRouteProfiles, utils.ConcatenatedKey(tenant, id), cacheCommit(utils.NonTransactional), utils.NonTransactional) return } + func (iDB *InternalDB) GetAttributeProfileDrv(tenant, id string) (attr *AttributeProfile, err error) { x, ok := iDB.db.Get(utils.CacheAttributeProfiles, utils.ConcatenatedKey(tenant, id)) if !ok || x == nil { @@ -1283,16 +1285,19 @@ func (iDB *InternalDB) GetAttributeProfileDrv(tenant, id string) (attr *Attribut } return x.(*AttributeProfile), nil } + func (iDB *InternalDB) SetAttributeProfileDrv(attr *AttributeProfile) (err error) { iDB.db.Set(utils.CacheAttributeProfiles, attr.TenantID(), attr, nil, cacheCommit(utils.NonTransactional), utils.NonTransactional) return } + func (iDB *InternalDB) RemoveAttributeProfileDrv(tenant, id string) (err error) { iDB.db.Remove(utils.CacheAttributeProfiles, utils.ConcatenatedKey(tenant, id), cacheCommit(utils.NonTransactional), utils.NonTransactional) return } + func (iDB *InternalDB) GetChargerProfileDrv(tenant, id string) (ch *ChargerProfile, err error) { x, ok := iDB.db.Get(utils.CacheChargerProfiles, utils.ConcatenatedKey(tenant, id)) if !ok || x == nil { @@ -1300,16 +1305,19 @@ func (iDB *InternalDB) GetChargerProfileDrv(tenant, id string) (ch *ChargerProfi } return x.(*ChargerProfile), nil } + func (iDB *InternalDB) SetChargerProfileDrv(chr *ChargerProfile) (err error) { iDB.db.Set(utils.CacheChargerProfiles, chr.TenantID(), chr, nil, cacheCommit(utils.NonTransactional), utils.NonTransactional) return } + func (iDB *InternalDB) RemoveChargerProfileDrv(tenant, id string) (err error) { iDB.db.Remove(utils.CacheChargerProfiles, utils.ConcatenatedKey(tenant, id), cacheCommit(utils.NonTransactional), utils.NonTransactional) return } + func (iDB *InternalDB) GetDispatcherProfileDrv(tenant, id string) (dpp *DispatcherProfile, err error) { x, ok := iDB.db.Get(utils.CacheDispatcherProfiles, utils.ConcatenatedKey(tenant, id)) if !ok || x == nil { @@ -1317,16 +1325,19 @@ func (iDB *InternalDB) GetDispatcherProfileDrv(tenant, id string) (dpp *Dispatch } return x.(*DispatcherProfile), nil } + func (iDB *InternalDB) SetDispatcherProfileDrv(dpp *DispatcherProfile) (err error) { iDB.db.Set(utils.CacheDispatcherProfiles, dpp.TenantID(), dpp, nil, cacheCommit(utils.NonTransactional), utils.NonTransactional) return } + func (iDB *InternalDB) RemoveDispatcherProfileDrv(tenant, id string) (err error) { iDB.db.Remove(utils.CacheDispatcherProfiles, utils.ConcatenatedKey(tenant, id), cacheCommit(utils.NonTransactional), utils.NonTransactional) return } + func (iDB *InternalDB) GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[string]int64, err error) { x, ok := iDB.db.Get(utils.CacheLoadIDs, utils.LoadIDs) if !ok || x == nil { @@ -1337,13 +1348,14 @@ func (iDB *InternalDB) GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[strin return map[string]int64{itemIDPrefix: loadIDs[itemIDPrefix]}, nil } return - } + func (iDB *InternalDB) SetLoadIDsDrv(loadIDs map[string]int64) (err error) { iDB.db.Set(utils.CacheLoadIDs, utils.LoadIDs, loadIDs, nil, cacheCommit(utils.NonTransactional), utils.NonTransactional) return } + func (iDB *InternalDB) GetDispatcherHostDrv(tenant, id string) (dpp *DispatcherHost, err error) { x, ok := iDB.db.Get(utils.CacheDispatcherHosts, utils.ConcatenatedKey(tenant, id)) if !ok || x == nil { @@ -1351,11 +1363,13 @@ func (iDB *InternalDB) GetDispatcherHostDrv(tenant, id string) (dpp *DispatcherH } return x.(*DispatcherHost), nil } + func (iDB *InternalDB) SetDispatcherHostDrv(dpp *DispatcherHost) (err error) { iDB.db.Set(utils.CacheDispatcherHosts, dpp.TenantID(), dpp, nil, cacheCommit(utils.NonTransactional), utils.NonTransactional) return } + func (iDB *InternalDB) RemoveDispatcherHostDrv(tenant, id string) (err error) { iDB.db.Remove(utils.CacheDispatcherHosts, utils.ConcatenatedKey(tenant, id), cacheCommit(utils.NonTransactional), utils.NonTransactional) diff --git a/engine/storage_internal_stordb.go b/engine/storage_internal_stordb.go index 006b212cf..24f75afeb 100644 --- a/engine/storage_internal_stordb.go +++ b/engine/storage_internal_stordb.go @@ -451,7 +451,7 @@ func (iDB *InternalDB) GetTPFilters(tpid, tenant, id string) (fltrs []*utils.TPF return } -func (iDB *InternalDB) GetTPSuppliers(tpid, tenant, id string) (supps []*utils.TPSupplierProfile, err error) { +func (iDB *InternalDB) GetTPRoutes(tpid, tenant, id string) (supps []*utils.TPRouteProfile, err error) { key := tpid if tenant != utils.EmptyString { key += utils.CONCATENATED_KEY_SEP + tenant @@ -459,13 +459,13 @@ func (iDB *InternalDB) GetTPSuppliers(tpid, tenant, id string) (supps []*utils.T if id != utils.EmptyString { key += utils.CONCATENATED_KEY_SEP + id } - ids := iDB.db.GetItemIDs(utils.TBLTPSuppliers, key) + ids := iDB.db.GetItemIDs(utils.TBLTPRoutes, key) for _, id := range ids { - x, ok := iDB.db.Get(utils.TBLTPSuppliers, id) + x, ok := iDB.db.Get(utils.TBLTPRoutes, id) if !ok || x == nil { return nil, utils.ErrNotFound } - supps = append(supps, x.(*utils.TPSupplierProfile)) + supps = append(supps, x.(*utils.TPRouteProfile)) } if len(supps) == 0 { @@ -750,12 +750,12 @@ func (iDB *InternalDB) SetTPFilters(filters []*utils.TPFilterProfile) (err error return } -func (iDB *InternalDB) SetTPSuppliers(suppliers []*utils.TPSupplierProfile) (err error) { - if len(suppliers) == 0 { +func (iDB *InternalDB) SetTPRoutes(routes []*utils.TPRouteProfile) (err error) { + if len(routes) == 0 { return nil } - for _, supplier := range suppliers { - iDB.db.Set(utils.TBLTPSuppliers, utils.ConcatenatedKey(supplier.TPid, supplier.Tenant, supplier.ID), supplier, nil, + for _, route := range routes { + iDB.db.Set(utils.TBLTPRoutes, utils.ConcatenatedKey(route.TPid, route.Tenant, route.ID), route, nil, cacheCommit(utils.NonTransactional), utils.NonTransactional) } return diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go index 658432ccd..07354eb9a 100644 --- a/engine/storage_mongo_datadb.go +++ b/engine/storage_mongo_datadb.go @@ -68,7 +68,7 @@ const ( ColTps = "threshold_profiles" ColThs = "thresholds" ColFlt = "filters" - ColSpp = "supplier_profiles" + ColRts = "route_profiles" ColAttr = "attribute_profiles" ColCDRs = "cdrs" ColCpp = "charger_profiles" @@ -286,7 +286,7 @@ func (ms *MongoStorage) ensureIndexesForCol(col string) (err error) { // exporte if err = ms.enusureIndex(col, true, "key"); err != nil { return } - case ColRsP, ColRes, ColSqs, ColSqp, ColTps, ColThs, ColSpp, ColAttr, ColFlt, ColCpp, ColDpp, ColDph: + case ColRsP, ColRes, ColSqs, ColSqp, ColTps, ColThs, ColRts, ColAttr, ColFlt, ColCpp, ColDpp, ColDph: if err = ms.enusureIndex(col, true, "tenant", "id"); err != nil { return } @@ -301,7 +301,7 @@ func (ms *MongoStorage) ensureIndexesForCol(col string) (err error) { // exporte utils.TBLTPActionPlans, utils.TBLTPActionTriggers, utils.TBLTPStats, utils.TBLTPResources, utils.TBLTPDispatchers, utils.TBLTPDispatcherHosts, utils.TBLTPChargers, - utils.TBLTPSuppliers, utils.TBLTPThresholds: + utils.TBLTPRoutes, utils.TBLTPThresholds: if err = ms.enusureIndex(col, true, "tpid", "id"); err != nil { return } @@ -350,7 +350,7 @@ func (ms *MongoStorage) EnsureIndexes(cols ...string) (err error) { if ms.storageType == utils.DataDB { for _, col := range []string{ColAct, ColApl, ColAAp, ColAtr, ColRpl, ColDst, ColRds, ColLht, ColRFI, ColRsP, ColRes, ColSqs, ColSqp, - ColTps, ColThs, ColSpp, ColAttr, ColFlt, ColCpp, ColDpp, + ColTps, ColThs, ColRts, ColAttr, ColFlt, ColCpp, ColDpp, ColRpf, ColShg, ColAcc} { if err = ms.ensureIndexesForCol(col); err != nil { return @@ -394,7 +394,7 @@ func (ms *MongoStorage) getColNameForPrefix(prefix string) (string, bool) { utils.StatQueueProfilePrefix: ColSqp, utils.ThresholdPrefix: ColThs, utils.FilterPrefix: ColFlt, - utils.SupplierProfilePrefix: ColSpp, + utils.RouteProfilePrefix: ColRts, utils.AttributeProfilePrefix: ColAttr, }[prefix] return res, ok @@ -673,8 +673,8 @@ func (ms *MongoStorage) GetKeysForPrefix(prefix string) (result []string, err er result, err = ms.getField2(sctx, ColThs, utils.ThresholdPrefix, subject, tntID) case utils.ThresholdProfilePrefix: result, err = ms.getField2(sctx, ColTps, utils.ThresholdProfilePrefix, subject, tntID) - case utils.SupplierProfilePrefix: - result, err = ms.getField2(sctx, ColSpp, utils.SupplierProfilePrefix, subject, tntID) + case utils.RouteProfilePrefix: + result, err = ms.getField2(sctx, ColRts, utils.RouteProfilePrefix, subject, tntID) case utils.AttributeProfilePrefix: result, err = ms.getField2(sctx, ColAttr, utils.AttributeProfilePrefix, subject, tntID) case utils.ChargerProfilePrefix: @@ -691,8 +691,8 @@ func (ms *MongoStorage) GetKeysForPrefix(prefix string) (result []string, err er result, err = ms.getField3(sctx, ColRFI, utils.StatFilterIndexes, "key") case utils.ThresholdFilterIndexes: result, err = ms.getField3(sctx, ColRFI, utils.ThresholdFilterIndexes, "key") - case utils.SupplierFilterIndexes: - result, err = ms.getField3(sctx, ColRFI, utils.SupplierFilterIndexes, "key") + case utils.RouteFilterIndexes: + result, err = ms.getField3(sctx, ColRFI, utils.RouteFilterIndexes, "key") case utils.ChargerFilterIndexes: result, err = ms.getField3(sctx, ColRFI, utils.ChargerFilterIndexes, "key") case utils.DispatcherFilterIndexes: @@ -735,8 +735,8 @@ func (ms *MongoStorage) HasDataDrv(category, subject, tenant string) (has bool, count, err = ms.getCol(ColTps).CountDocuments(sctx, bson.M{"tenant": tenant, "id": subject}) case utils.FilterPrefix: count, err = ms.getCol(ColFlt).CountDocuments(sctx, bson.M{"tenant": tenant, "id": subject}) - case utils.SupplierProfilePrefix: - count, err = ms.getCol(ColSpp).CountDocuments(sctx, bson.M{"tenant": tenant, "id": subject}) + case utils.RouteProfilePrefix: + count, err = ms.getCol(ColRts).CountDocuments(sctx, bson.M{"tenant": tenant, "id": subject}) case utils.AttributeProfilePrefix: count, err = ms.getCol(ColAttr).CountDocuments(sctx, bson.M{"tenant": tenant, "id": subject}) case utils.ChargerProfilePrefix: @@ -2076,10 +2076,10 @@ func (ms *MongoStorage) RemoveFilterDrv(tenant, id string) (err error) { }) } -func (ms *MongoStorage) GetSupplierProfileDrv(tenant, id string) (r *SupplierProfile, err error) { - r = new(SupplierProfile) +func (ms *MongoStorage) GetRouteProfileDrv(tenant, id string) (r *RouteProfile, err error) { + r = new(RouteProfile) err = ms.query(func(sctx mongo.SessionContext) (err error) { - cur := ms.getCol(ColSpp).FindOne(sctx, bson.M{"tenant": tenant, "id": id}) + cur := ms.getCol(ColRts).FindOne(sctx, bson.M{"tenant": tenant, "id": id}) if err := cur.Decode(r); err != nil { r = nil if err == mongo.ErrNoDocuments { @@ -2092,9 +2092,9 @@ func (ms *MongoStorage) GetSupplierProfileDrv(tenant, id string) (r *SupplierPro return } -func (ms *MongoStorage) SetSupplierProfileDrv(r *SupplierProfile) (err error) { +func (ms *MongoStorage) SetRouteProfileDrv(r *RouteProfile) (err error) { return ms.query(func(sctx mongo.SessionContext) (err error) { - _, err = ms.getCol(ColSpp).UpdateOne(sctx, bson.M{"tenant": r.Tenant, "id": r.ID}, + _, err = ms.getCol(ColRts).UpdateOne(sctx, bson.M{"tenant": r.Tenant, "id": r.ID}, bson.M{"$set": r}, options.Update().SetUpsert(true), ) @@ -2102,9 +2102,9 @@ func (ms *MongoStorage) SetSupplierProfileDrv(r *SupplierProfile) (err error) { }) } -func (ms *MongoStorage) RemoveSupplierProfileDrv(tenant, id string) (err error) { +func (ms *MongoStorage) RemoveRouteProfileDrv(tenant, id string) (err error) { return ms.query(func(sctx mongo.SessionContext) (err error) { - dr, err := ms.getCol(ColSpp).DeleteOne(sctx, bson.M{"tenant": tenant, "id": id}) + dr, err := ms.getCol(ColRts).DeleteOne(sctx, bson.M{"tenant": tenant, "id": id}) if dr.DeletedCount == 0 { return utils.ErrNotFound } diff --git a/engine/storage_mongo_stordb.go b/engine/storage_mongo_stordb.go index d62662968..58ce4dbaa 100644 --- a/engine/storage_mongo_stordb.go +++ b/engine/storage_mongo_stordb.go @@ -1291,7 +1291,7 @@ func (ms *MongoStorage) SetTPFilters(tpTHs []*utils.TPFilterProfile) (err error) }) } -func (ms *MongoStorage) GetTPSuppliers(tpid, tenant, id string) ([]*utils.TPSupplierProfile, error) { +func (ms *MongoStorage) GetTPRoutes(tpid, tenant, id string) ([]*utils.TPRouteProfile, error) { filter := bson.M{"tpid": tpid} if id != "" { filter["id"] = id @@ -1299,14 +1299,14 @@ func (ms *MongoStorage) GetTPSuppliers(tpid, tenant, id string) ([]*utils.TPSupp if tenant != "" { filter["tenant"] = tenant } - var results []*utils.TPSupplierProfile + var results []*utils.TPRouteProfile err := ms.query(func(sctx mongo.SessionContext) (err error) { - cur, err := ms.getCol(utils.TBLTPSuppliers).Find(sctx, filter) + cur, err := ms.getCol(utils.TBLTPRoutes).Find(sctx, filter) if err != nil { return err } for cur.Next(sctx) { - var tp utils.TPSupplierProfile + var tp utils.TPRouteProfile err := cur.Decode(&tp) if err != nil { return err @@ -1321,13 +1321,13 @@ func (ms *MongoStorage) GetTPSuppliers(tpid, tenant, id string) ([]*utils.TPSupp return results, err } -func (ms *MongoStorage) SetTPSuppliers(tpSPs []*utils.TPSupplierProfile) (err error) { - if len(tpSPs) == 0 { +func (ms *MongoStorage) SetTPRoutes(tpRoutes []*utils.TPRouteProfile) (err error) { + if len(tpRoutes) == 0 { return } return ms.query(func(sctx mongo.SessionContext) (err error) { - for _, tp := range tpSPs { - _, err = ms.getCol(utils.TBLTPSuppliers).UpdateOne(sctx, bson.M{"tpid": tp.TPid, "id": tp.ID}, + for _, tp := range tpRoutes { + _, err = ms.getCol(utils.TBLTPRoutes).UpdateOne(sctx, bson.M{"tpid": tp.TPid, "id": tp.ID}, bson.M{"$set": tp}, options.Update().SetUpsert(true), ) @@ -1369,12 +1369,12 @@ func (ms *MongoStorage) GetTPAttributes(tpid, tenant, id string) ([]*utils.TPAtt return results, err } -func (ms *MongoStorage) SetTPAttributes(tpSPs []*utils.TPAttributeProfile) (err error) { - if len(tpSPs) == 0 { +func (ms *MongoStorage) SetTPAttributes(tpRoutes []*utils.TPAttributeProfile) (err error) { + if len(tpRoutes) == 0 { return } return ms.query(func(sctx mongo.SessionContext) (err error) { - for _, tp := range tpSPs { + for _, tp := range tpRoutes { _, err = ms.getCol(utils.TBLTPAttributes).UpdateOne(sctx, bson.M{"tpid": tp.TPid, "id": tp.ID}, bson.M{"$set": tp}, options.Update().SetUpsert(true), diff --git a/engine/storage_redis.go b/engine/storage_redis.go index 7dbb674a3..0df5069f3 100644 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -413,7 +413,7 @@ func (rs *RedisStorage) HasDataDrv(category, subject, tenant string) (bool, erro return i == 1, err case utils.ResourcesPrefix, utils.ResourceProfilesPrefix, utils.StatQueuePrefix, utils.StatQueueProfilePrefix, utils.ThresholdPrefix, utils.ThresholdProfilePrefix, - utils.FilterPrefix, utils.SupplierProfilePrefix, utils.AttributeProfilePrefix, + utils.FilterPrefix, utils.RouteProfilePrefix, utils.AttributeProfilePrefix, utils.ChargerProfilePrefix, utils.DispatcherProfilePrefix, utils.DispatcherHostPrefix: i, err := rs.Cmd(redis_EXISTS, category+utils.ConcatenatedKey(tenant, subject)).Int() return i == 1, err @@ -1489,8 +1489,8 @@ func (rs *RedisStorage) RemoveFilterDrv(tenant, id string) (err error) { return } -func (rs *RedisStorage) GetSupplierProfileDrv(tenant, id string) (r *SupplierProfile, err error) { - key := utils.SupplierProfilePrefix + utils.ConcatenatedKey(tenant, id) +func (rs *RedisStorage) GetRouteProfileDrv(tenant, id string) (r *RouteProfile, err error) { + key := utils.RouteProfilePrefix + utils.ConcatenatedKey(tenant, id) var values []byte if values, err = rs.Cmd(redis_GET, key).Bytes(); err != nil { if err == redis.ErrRespNil { // did not find the destination @@ -1504,16 +1504,16 @@ func (rs *RedisStorage) GetSupplierProfileDrv(tenant, id string) (r *SupplierPro return } -func (rs *RedisStorage) SetSupplierProfileDrv(r *SupplierProfile) (err error) { +func (rs *RedisStorage) SetRouteProfileDrv(r *RouteProfile) (err error) { result, err := rs.ms.Marshal(r) if err != nil { return err } - return rs.Cmd(redis_SET, utils.SupplierProfilePrefix+utils.ConcatenatedKey(r.Tenant, r.ID), result).Err + return rs.Cmd(redis_SET, utils.RouteProfilePrefix+utils.ConcatenatedKey(r.Tenant, r.ID), result).Err } -func (rs *RedisStorage) RemoveSupplierProfileDrv(tenant, id string) (err error) { - key := utils.SupplierProfilePrefix + utils.ConcatenatedKey(tenant, id) +func (rs *RedisStorage) RemoveRouteProfileDrv(tenant, id string) (err error) { + key := utils.RouteProfilePrefix + utils.ConcatenatedKey(tenant, id) if err = rs.Cmd(redis_DEL, key).Err; err != nil { return } diff --git a/engine/storage_sql.go b/engine/storage_sql.go index e17c2947f..faace2d39 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -104,7 +104,7 @@ func (self *SQLStorage) IsDBEmpty() (resp bool, err error) { utils.TBLTPSharedGroups, utils.TBLTPActions, utils.TBLTPActionTriggers, utils.TBLTPAccountActions, utils.TBLTPResources, utils.TBLTPStats, utils.TBLTPThresholds, utils.TBLTPFilters, utils.SessionCostsTBL, utils.CDRsTBL, utils.TBLTPActionPlans, - utils.TBLVersions, utils.TBLTPSuppliers, utils.TBLTPAttributes, utils.TBLTPChargers, + utils.TBLVersions, utils.TBLTPRoutes, utils.TBLTPAttributes, utils.TBLTPChargers, utils.TBLTPDispatchers, utils.TBLTPDispatcherHosts, } for _, tbl := range tbls { @@ -140,7 +140,7 @@ func (self *SQLStorage) GetTpIds(colName string) ([]string, error) { utils.TBLTPThresholds, utils.TBLTPFilters, utils.TBLTPActionPlans, - utils.TBLTPSuppliers, + utils.TBLTPRoutes, utils.TBLTPAttributes, utils.TBLTPChargers, utils.TBLTPDispatchers, @@ -238,7 +238,7 @@ func (self *SQLStorage) RemTpData(table, tpid string, args map[string]string) er utils.TBLTPSharedGroups, utils.TBLTPActions, utils.TBLTPActionPlans, utils.TBLTPActionTriggers, utils.TBLTPAccountActions, utils.TBLTPResources, utils.TBLTPStats, utils.TBLTPFilters, - utils.TBLTPSuppliers, utils.TBLTPAttributes, + utils.TBLTPRoutes, utils.TBLTPAttributes, utils.TBLTPChargers, utils.TBLTPDispatchers, utils.TBLTPDispatcherHosts} { if err := tx.Table(tblName).Where("tpid = ?", tpid).Delete(nil).Error; err != nil { tx.Rollback() @@ -618,18 +618,18 @@ func (self *SQLStorage) SetTPFilters(ths []*utils.TPFilterProfile) error { return nil } -func (self *SQLStorage) SetTPSuppliers(tpSPs []*utils.TPSupplierProfile) error { - if len(tpSPs) == 0 { +func (self *SQLStorage) SetTPRoutes(tpRoutes []*utils.TPRouteProfile) error { + if len(tpRoutes) == 0 { return nil } tx := self.db.Begin() - for _, stq := range tpSPs { + for _, tpRoute := range tpRoutes { // Remove previous - if err := tx.Where(&TpSupplier{Tpid: stq.TPid, ID: stq.ID}).Delete(TpSupplier{}).Error; err != nil { + if err := tx.Where(&TpRoute{Tpid: tpRoute.TPid, ID: tpRoute.ID}).Delete(TpRoute{}).Error; err != nil { tx.Rollback() return err } - for _, mst := range APItoModelTPSuppliers(stq) { + for _, mst := range APItoModelTPRoutes(tpRoute) { if err := tx.Save(&mst).Error; err != nil { tx.Rollback() return err @@ -1478,8 +1478,8 @@ func (self *SQLStorage) GetTPFilters(tpid, tenant, id string) ([]*utils.TPFilter return aths, nil } -func (self *SQLStorage) GetTPSuppliers(tpid, tenant, id string) ([]*utils.TPSupplierProfile, error) { - var sps TpSuppliers +func (self *SQLStorage) GetTPRoutes(tpid, tenant, id string) ([]*utils.TPRouteProfile, error) { + var tpRoutes TPRoutes q := self.db.Where("tpid = ?", tpid) if len(id) != 0 { q = q.Where("id = ?", id) @@ -1487,14 +1487,14 @@ func (self *SQLStorage) GetTPSuppliers(tpid, tenant, id string) ([]*utils.TPSupp if len(tenant) != 0 { q = q.Where("tenant = ?", tenant) } - if err := q.Find(&sps).Error; err != nil { + if err := q.Find(&tpRoutes).Error; err != nil { return nil, err } - arls := sps.AsTPSuppliers() - if len(arls) == 0 { - return arls, utils.ErrNotFound + aTpRoutes := tpRoutes.AsTPRouteProfile() + if len(aTpRoutes) == 0 { + return aTpRoutes, utils.ErrNotFound } - return arls, nil + return aTpRoutes, nil } func (self *SQLStorage) GetTPAttributes(tpid, tenant, id string) ([]*utils.TPAttributeProfile, error) { diff --git a/engine/tpexporter.go b/engine/tpexporter.go index 6adb5b66f..bbd908aca 100644 --- a/engine/tpexporter.go +++ b/engine/tpexporter.go @@ -251,14 +251,14 @@ func (self *TPExporter) Run() error { } } - storDataSuppliers, err := self.storDb.GetTPSuppliers(self.tpID, "", "") + storDataRoutes, err := self.storDb.GetTPRoutes(self.tpID, "", "") if err != nil && err.Error() != utils.ErrNotFound.Error() { return err } - for _, sd := range storDataSuppliers { - sdModels := APItoModelTPSuppliers(sd) + for _, sd := range storDataRoutes { + sdModels := APItoModelTPRoutes(sd) for _, sdModel := range sdModels { - toExportMap[utils.SuppliersCsv] = append(toExportMap[utils.SuppliersCsv], sdModel) + toExportMap[utils.RoutesCsv] = append(toExportMap[utils.RoutesCsv], sdModel) } } diff --git a/engine/tpimporter_csv.go b/engine/tpimporter_csv.go index 1d108f05d..67b97d5df 100644 --- a/engine/tpimporter_csv.go +++ b/engine/tpimporter_csv.go @@ -55,7 +55,7 @@ var fileHandlers = map[string]func(*TPCSVImporter, string) error{ utils.StatsCsv: (*TPCSVImporter).importStats, utils.ThresholdsCsv: (*TPCSVImporter).importThresholds, utils.FiltersCsv: (*TPCSVImporter).importFilters, - utils.SuppliersCsv: (*TPCSVImporter).importSuppliers, + utils.RoutesCsv: (*TPCSVImporter).importRoutes, utils.AttributesCsv: (*TPCSVImporter).importAttributeProfiles, utils.ChargersCsv: (*TPCSVImporter).importChargerProfiles, utils.DispatcherProfilesCsv: (*TPCSVImporter).importDispatcherProfiles, @@ -303,15 +303,15 @@ func (self *TPCSVImporter) importFilters(fn string) error { return self.StorDb.SetTPFilters(sts) } -func (self *TPCSVImporter) importSuppliers(fn string) error { +func (self *TPCSVImporter) importRoutes(fn string) error { if self.Verbose { log.Printf("Processing file: <%s> ", fn) } - rls, err := self.csvr.GetTPSuppliers(self.TPid, "", "") + rls, err := self.csvr.GetTPRoutes(self.TPid, "", "") if err != nil { return err } - return self.StorDb.SetTPSuppliers(rls) + return self.StorDb.SetTPRoutes(rls) } func (self *TPCSVImporter) importAttributeProfiles(fn string) error { diff --git a/engine/tpreader.go b/engine/tpreader.go index 0b27b1ba9..0a712c297 100644 --- a/engine/tpreader.go +++ b/engine/tpreader.go @@ -51,7 +51,7 @@ type TpReader struct { sqProfiles map[utils.TenantID]*utils.TPStatProfile thProfiles map[utils.TenantID]*utils.TPThresholdProfile filters map[utils.TenantID]*utils.TPFilterProfile - sppProfiles map[utils.TenantID]*utils.TPSupplierProfile + routeProfiles map[utils.TenantID]*utils.TPRouteProfile attributeProfiles map[utils.TenantID]*utils.TPAttributeProfile chargerProfiles map[utils.TenantID]*utils.TPChargerProfile dispatcherProfiles map[utils.TenantID]*utils.TPDispatcherProfile @@ -132,7 +132,7 @@ func (tpr *TpReader) Init() { tpr.resProfiles = make(map[utils.TenantID]*utils.TPResourceProfile) tpr.sqProfiles = make(map[utils.TenantID]*utils.TPStatProfile) tpr.thProfiles = make(map[utils.TenantID]*utils.TPThresholdProfile) - tpr.sppProfiles = make(map[utils.TenantID]*utils.TPSupplierProfile) + tpr.routeProfiles = make(map[utils.TenantID]*utils.TPRouteProfile) tpr.attributeProfiles = make(map[utils.TenantID]*utils.TPAttributeProfile) tpr.chargerProfiles = make(map[utils.TenantID]*utils.TPChargerProfile) tpr.dispatcherProfiles = make(map[utils.TenantID]*utils.TPDispatcherProfile) @@ -1197,21 +1197,21 @@ func (tpr *TpReader) LoadFilters() error { return tpr.LoadFiltersFiltered("") } -func (tpr *TpReader) LoadSupplierProfilesFiltered(tag string) (err error) { - rls, err := tpr.lr.GetTPSuppliers(tpr.tpid, "", tag) +func (tpr *TpReader) LoadRouteProfilesFiltered(tag string) (err error) { + rls, err := tpr.lr.GetTPRoutes(tpr.tpid, "", tag) if err != nil { return err } - mapRsPfls := make(map[utils.TenantID]*utils.TPSupplierProfile) + mapRsPfls := make(map[utils.TenantID]*utils.TPRouteProfile) for _, rl := range rls { mapRsPfls[utils.TenantID{Tenant: rl.Tenant, ID: rl.ID}] = rl } - tpr.sppProfiles = mapRsPfls + tpr.routeProfiles = mapRsPfls return nil } -func (tpr *TpReader) LoadSupplierProfiles() error { - return tpr.LoadSupplierProfilesFiltered("") +func (tpr *TpReader) LoadRouteProfiles() error { + return tpr.LoadRouteProfilesFiltered("") } func (tpr *TpReader) LoadAttributeProfilesFiltered(tag string) (err error) { @@ -1328,7 +1328,7 @@ func (tpr *TpReader) LoadAll() (err error) { if err = tpr.LoadThresholds(); err != nil && err.Error() != utils.NotFoundCaps { return } - if err = tpr.LoadSupplierProfiles(); err != nil && err.Error() != utils.NotFoundCaps { + if err = tpr.LoadRouteProfiles(); err != nil && err.Error() != utils.NotFoundCaps { return } if err = tpr.LoadAttributeProfiles(); err != nil && err.Error() != utils.NotFoundCaps { @@ -1660,22 +1660,22 @@ func (tpr *TpReader) WriteToDatabase(verbose, disable_reverse bool) (err error) loadIDs[utils.CacheThresholds] = loadID } if verbose { - log.Print("SupplierProfiles:") + log.Print("RouteProfiles:") } - for _, tpTH := range tpr.sppProfiles { - th, err := APItoSupplierProfile(tpTH, tpr.timezone) + for _, tpTH := range tpr.routeProfiles { + th, err := APItoRouteProfile(tpTH, tpr.timezone) if err != nil { return err } - if err = tpr.dm.SetSupplierProfile(th, true); err != nil { + if err = tpr.dm.SetRouteProfile(th, true); err != nil { return err } if verbose { log.Print("\t", th.TenantID()) } } - if len(tpr.sppProfiles) != 0 { - loadIDs[utils.CacheSupplierProfiles] = loadID + if len(tpr.routeProfiles) != 0 { + loadIDs[utils.CacheRouteProfiles] = loadID } if verbose { log.Print("AttributeProfiles:") @@ -1845,8 +1845,8 @@ func (tpr *TpReader) ShowStatistics() { log.Print("Thresholds: ", len(tpr.thProfiles)) // filters log.Print("Filters: ", len(tpr.filters)) - // Supplier profiles - log.Print("SupplierProfiles: ", len(tpr.sppProfiles)) + // Route profiles + log.Print("RouteProfiles: ", len(tpr.routeProfiles)) // Attribute profiles log.Print("AttributeProfiles: ", len(tpr.attributeProfiles)) // Charger profiles @@ -1964,10 +1964,10 @@ func (tpr *TpReader) GetLoadedIds(categ string) ([]string, error) { i++ } return keys, nil - case utils.SupplierProfilePrefix: - keys := make([]string, len(tpr.sppProfiles)) + case utils.RouteProfilePrefix: + keys := make([]string, len(tpr.routeProfiles)) i := 0 - for k := range tpr.sppProfiles { + for k := range tpr.routeProfiles { keys[i] = k.TenantID() i++ } @@ -2185,10 +2185,10 @@ func (tpr *TpReader) RemoveFromDatabase(verbose, disable_reverse bool) (err erro } if verbose { - log.Print("SupplierProfiles:") + log.Print("RouteProfiles:") } - for _, tpSpl := range tpr.sppProfiles { - if err = tpr.dm.RemoveSupplierProfile(tpSpl.Tenant, tpSpl.ID, utils.NonTransactional, true); err != nil { + for _, tpSpl := range tpr.routeProfiles { + if err = tpr.dm.RemoveRouteProfile(tpSpl.Tenant, tpSpl.ID, utils.NonTransactional, true); err != nil { return err } if verbose { @@ -2337,8 +2337,8 @@ func (tpr *TpReader) RemoveFromDatabase(verbose, disable_reverse bool) (err erro if len(tpr.thresholds) != 0 { loadIDs[utils.CacheThresholds] = loadID } - if len(tpr.sppProfiles) != 0 { - loadIDs[utils.CacheSupplierProfiles] = loadID + if len(tpr.routeProfiles) != 0 { + loadIDs[utils.CacheRouteProfiles] = loadID } if len(tpr.attributeProfiles) != 0 { loadIDs[utils.CacheAttributeProfiles] = loadID @@ -2382,7 +2382,7 @@ func (tpr *TpReader) ReloadCache(caching string, verbose bool, argDispatcher *ut trsIDs, _ := tpr.GetLoadedIds(utils.ThresholdPrefix) trspfIDs, _ := tpr.GetLoadedIds(utils.ThresholdProfilePrefix) flrIDs, _ := tpr.GetLoadedIds(utils.FilterPrefix) - spfIDs, _ := tpr.GetLoadedIds(utils.SupplierProfilePrefix) + routeIDs, _ := tpr.GetLoadedIds(utils.RouteProfilePrefix) apfIDs, _ := tpr.GetLoadedIds(utils.AttributeProfilePrefix) chargerIDs, _ := tpr.GetLoadedIds(utils.ChargerProfilePrefix) dppIDs, _ := tpr.GetLoadedIds(utils.DispatcherProfilePrefix) @@ -2410,7 +2410,7 @@ func (tpr *TpReader) ReloadCache(caching string, verbose bool, argDispatcher *ut ThresholdIDs: &trsIDs, ThresholdProfileIDs: &trspfIDs, FilterIDs: &flrIDs, - SupplierProfileIDs: &spfIDs, + RouteProfileIDs: &routeIDs, AttributeProfileIDs: &apfIDs, ChargerProfileIDs: &chargerIDs, DispatcherProfileIDs: &dppIDs, @@ -2450,8 +2450,8 @@ func (tpr *TpReader) ReloadCache(caching string, verbose bool, argDispatcher *ut if len(apfIDs) != 0 { cacheIDs = append(cacheIDs, utils.CacheAttributeFilterIndexes) } - if len(spfIDs) != 0 { - cacheIDs = append(cacheIDs, utils.CacheSupplierFilterIndexes) + if len(routeIDs) != 0 { + cacheIDs = append(cacheIDs, utils.CacheRouteFilterIndexes) } if len(trspfIDs) != 0 { cacheIDs = append(cacheIDs, utils.CacheThresholdFilterIndexes) diff --git a/engine/version.go b/engine/version.go index 93afbbae3..f4e06b0f6 100644 --- a/engine/version.go +++ b/engine/version.go @@ -150,7 +150,7 @@ func CurrentDataDBVersions() Versions { utils.ActionPlans: 3, utils.SharedGroups: 2, utils.Thresholds: 3, - utils.Suppliers: 1, + utils.Routes: 1, utils.Attributes: 5, utils.Timing: 1, utils.RQF: 4, @@ -180,7 +180,7 @@ func CurrentStorDBVersions() Versions { utils.TpActionPlans: 1, utils.TpActions: 1, utils.TpThresholds: 1, - utils.TpSuppliers: 1, + utils.TpRoutes: 1, utils.TpStats: 1, utils.TpSharedGroups: 1, utils.TpRatingProfiles: 1, diff --git a/servmanager/servmanager.go b/servmanager/servmanager.go index ec1a56483..94ee3ffe5 100644 --- a/servmanager/servmanager.go +++ b/servmanager/servmanager.go @@ -156,7 +156,7 @@ func (srvMngr *ServiceManager) StartServices() (err error) { utils.ThresholdS: srvMngr.GetConfig().ThresholdSCfg().Enabled, utils.StatS: srvMngr.GetConfig().StatSCfg().Enabled, utils.ResourceS: srvMngr.GetConfig().ResourceSCfg().Enabled, - utils.SupplierS: srvMngr.GetConfig().SupplierSCfg().Enabled, + utils.RouteS: srvMngr.GetConfig().RouteCfg().Enabled, utils.SchedulerS: srvMngr.GetConfig().SchedulerCfg().Enabled, utils.RALService: srvMngr.GetConfig().RalsCfg().Enabled, utils.CDRServer: srvMngr.GetConfig().CdrsCfg().Enabled, @@ -229,8 +229,8 @@ func (srvMngr *ServiceManager) handleReload() { if err = srvMngr.reloadService(utils.ResourceS); err != nil { return } - case <-srvMngr.GetConfig().GetReloadChan(config.SupplierSJson): - if err = srvMngr.reloadService(utils.SupplierS); err != nil { + case <-srvMngr.GetConfig().GetReloadChan(config.RouteSJson): + if err = srvMngr.reloadService(utils.RouteS); err != nil { return } case <-srvMngr.GetConfig().GetReloadChan(config.SCHEDULER_JSN): diff --git a/utils/apitpdata.go b/utils/apitpdata.go index e9ffd19f3..49ec52cfe 100755 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -451,7 +451,7 @@ type ArgsCache struct { ThresholdIDs *[]string ThresholdProfileIDs *[]string FilterIDs *[]string - SupplierProfileIDs *[]string + RouteProfileIDs *[]string AttributeProfileIDs *[]string ChargerProfileIDs *[]string DispatcherProfileIDs *[]string @@ -488,7 +488,7 @@ func InitAttrReloadCache() (rpl AttrReloadCache) { rpl.ThresholdIDs = &[]string{} rpl.ThresholdProfileIDs = &[]string{} rpl.FilterIDs = &[]string{} - rpl.SupplierProfileIDs = &[]string{} + rpl.RouteProfileIDs = &[]string{} rpl.AttributeProfileIDs = &[]string{} rpl.ChargerProfileIDs = &[]string{} rpl.DispatcherProfileIDs = &[]string{} diff --git a/utils/cgrevent.go b/utils/cgrevent.go index 0b76fb73e..88fe38428 100644 --- a/utils/cgrevent.go +++ b/utils/cgrevent.go @@ -206,18 +206,19 @@ func getArgDispatcherFromOpts(ev map[string]interface{}) (arg *ArgDispatcher) { return } -// getSupplierPaginatorFromOpts will consume supplierPaginator if present -func getSupplierPaginatorFromOpts(ev map[string]interface{}) (args *Paginator, err error) { +// consumeRoutePaginator will consume routePaginator if presented +func (ev *CGREvent) consumeRoutePaginator() (args *Paginator) { args = new(Paginator) if ev == nil { return } //check if we have suppliersLimit in event and in case it has add it in args - limitIface, hasSuppliersLimit := ev[SuppliersLimit] - if hasSuppliersLimit { - delete(ev, SuppliersLimit) - var limit int64 - if limit, err = IfaceAsInt64(limitIface); err != nil { + limitIface, hasRoutesLimit := ev.Event[MetaRoutesLimit] + if hasRoutesLimit { + delete(ev.Event, MetaRoutesLimit) + limit, err := IfaceAsInt64(limitIface) + if err != nil { + Logger.Err(err.Error()) return } args = &Paginator{ @@ -225,18 +226,20 @@ func getSupplierPaginatorFromOpts(ev map[string]interface{}) (args *Paginator, e } } //check if we have offset in event and in case it has add it in args - offsetIface, hasSuppliersOffset := ev[SuppliersOffset] - if !hasSuppliersOffset { - return - } - delete(ev, SuppliersOffset) - var offset int64 - if offset, err = IfaceAsInt64(offsetIface); err != nil { - return - } - if !hasSuppliersLimit { //in case we don't have limit, but we have offset we need to initialize the struct - args = &Paginator{ - Offset: IntPointer(int(offset)), + offsetIface, hasRoutesOffset := ev.Event[MetaRoutesOffset] + if hasRoutesOffset { + delete(ev.Event, MetaRoutesOffset) + offset, err := IfaceAsInt64(offsetIface) + if err != nil { + Logger.Err(err.Error()) + return + } + if !hasRoutesLimit { //in case we don't have limit, but we have offset we need to initialize the struct + args = &Paginator{ + Offset: IntPointer(int(offset)), + } + } else { + args.Offset = IntPointer(int(offset)) } return } @@ -244,16 +247,55 @@ func getSupplierPaginatorFromOpts(ev map[string]interface{}) (args *Paginator, e return } -// ExtractArgsFromOpts extracts the posible arguments(ArgDispatcher and SupplierPaginator) from options -func ExtractArgsFromOpts(ev map[string]interface{}, dispatcherFlag, consumeSupplierPaginator bool) (ca ExtractedArgs, err error) { +// ExtractedArgs stores the extracted arguments from CGREvent +type ExtractedArgs struct { + ArgDispatcher *ArgDispatcher + RoutePaginator *Paginator +} + +// ExtractArgs extracts the ArgDispatcher and RoutePaginator from the received event +func (ev *CGREvent) ExtractArgs(dispatcherFlag, consumeRoutePaginator bool) (ca ExtractedArgs) { ca = ExtractedArgs{ ArgDispatcher: getArgDispatcherFromOpts(ev), } if dispatcherFlag && ca.ArgDispatcher == nil { ca.ArgDispatcher = new(ArgDispatcher) } - if consumeSupplierPaginator { - ca.SupplierPaginator, err = getSupplierPaginatorFromOpts(ev) + if consumeRoutePaginator { + ca.RoutePaginator = ev.consumeRoutePaginator() + } + return +} + +// CGREvents is a group of generic events processed by CGR services +// ie: derived CDRs +type CGREvents struct { + Tenant string + ID string + Time *time.Time // event time + Events []map[string]interface{} +} + +func NewCGREventWithArgDispatcher() *CGREventWithArgDispatcher { + return new(CGREventWithArgDispatcher) +} + +type CGREventWithArgDispatcher struct { + *CGREvent + *ArgDispatcher +} + +func (ev *CGREventWithArgDispatcher) Clone() (clned *CGREventWithArgDispatcher) { + if ev == nil { + return + } + clned = new(CGREventWithArgDispatcher) + if ev.CGREvent != nil { + clned.CGREvent = ev.CGREvent.Clone() + } + if ev.ArgDispatcher != nil { + clned.ArgDispatcher = new(ArgDispatcher) + *clned.ArgDispatcher = *ev.ArgDispatcher } return } diff --git a/utils/consts.go b/utils/consts.go index 765e7d705..5fd5edc6b 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -27,7 +27,7 @@ var ( PreRated, CostSource, CostDetails, ExtraInfo, OrderID}) PostPaidRatedSlice = []string{META_POSTPAID, META_RATED} ItemList = NewStringSet([]string{MetaAccounts, MetaAttributes, MetaChargers, MetaDispatchers, MetaDispatcherHosts, - MetaFilters, MetaResources, MetaStats, MetaThresholds, MetaSuppliers, + MetaFilters, MetaResources, MetaStats, MetaThresholds, MetaRoutes, }) AttrInlineTypes = NewStringSet([]string{META_CONSTANT, MetaVariable, META_COMPOSED, META_USAGE_DIFFERENCE, MetaSum, MetaValueExponent}) @@ -64,9 +64,9 @@ var ( CacheAccountActionPlans, CacheActionTriggers, CacheSharedGroups, CacheTimings, CacheResourceProfiles, CacheResources, CacheEventResources, CacheStatQueueProfiles, CacheStatQueues, CacheThresholdProfiles, CacheThresholds, CacheFilters, - CacheSupplierProfiles, CacheAttributeProfiles, CacheChargerProfiles, + CacheRouteProfiles, CacheAttributeProfiles, CacheChargerProfiles, CacheDispatcherProfiles, CacheDispatcherHosts, CacheDispatchers, CacheResourceFilterIndexes, - CacheStatFilterIndexes, CacheThresholdFilterIndexes, CacheSupplierFilterIndexes, + CacheStatFilterIndexes, CacheThresholdFilterIndexes, CacheRouteFilterIndexes, CacheAttributeFilterIndexes, CacheChargerFilterIndexes, CacheDispatcherFilterIndexes, CacheDispatcherRoutes, CacheDispatcherLoads, CacheDiameterMessages, CacheRPCResponses, CacheClosedSessions, CacheCDRIDs, CacheLoadIDs, CacheRPCConnections, CacheRatingProfilesTmp, @@ -89,7 +89,7 @@ var ( CacheThresholdProfiles: ThresholdProfilePrefix, CacheThresholds: ThresholdPrefix, CacheFilters: FilterPrefix, - CacheSupplierProfiles: SupplierProfilePrefix, + CacheRouteProfiles: RouteProfilePrefix, CacheAttributeProfiles: AttributeProfilePrefix, CacheChargerProfiles: ChargerProfilePrefix, CacheDispatcherProfiles: DispatcherProfilePrefix, @@ -97,7 +97,7 @@ var ( CacheResourceFilterIndexes: ResourceFilterIndexes, CacheStatFilterIndexes: StatFilterIndexes, CacheThresholdFilterIndexes: ThresholdFilterIndexes, - CacheSupplierFilterIndexes: SupplierFilterIndexes, + CacheRouteFilterIndexes: RouteFilterIndexes, CacheAttributeFilterIndexes: AttributeFilterIndexes, CacheChargerFilterIndexes: ChargerFilterIndexes, CacheDispatcherFilterIndexes: DispatcherFilterIndexes, @@ -109,7 +109,7 @@ var ( ThresholdProfilePrefix: CacheThresholdFilterIndexes, ResourceProfilesPrefix: CacheResourceFilterIndexes, StatQueueProfilePrefix: CacheStatFilterIndexes, - SupplierProfilePrefix: CacheSupplierFilterIndexes, + RouteProfilePrefix: CacheRouteFilterIndexes, AttributeProfilePrefix: CacheAttributeFilterIndexes, ChargerProfilePrefix: CacheChargerFilterIndexes, DispatcherProfilePrefix: CacheDispatcherFilterIndexes, @@ -126,16 +126,16 @@ var ( CacheRatingPlans, CacheRatingProfiles, CacheActions, CacheActionPlans, CacheAccountActionPlans, CacheActionTriggers, CacheSharedGroups, CacheResourceProfiles, CacheResources, CacheTimings, CacheStatQueueProfiles, CacheStatQueues, CacheThresholdProfiles, CacheThresholds, - CacheFilters, CacheSupplierProfiles, CacheAttributeProfiles, CacheChargerProfiles, + CacheFilters, CacheRouteProfiles, CacheAttributeProfiles, CacheChargerProfiles, CacheDispatcherProfiles, CacheDispatcherHosts, CacheResourceFilterIndexes, CacheStatFilterIndexes, - CacheThresholdFilterIndexes, CacheSupplierFilterIndexes, CacheAttributeFilterIndexes, + CacheThresholdFilterIndexes, CacheRouteFilterIndexes, CacheAttributeFilterIndexes, CacheChargerFilterIndexes, CacheDispatcherFilterIndexes, CacheLoadIDs, CacheAccounts}) CacheStorDBPartitions = NewStringSet([]string{TBLTPTimings, TBLTPDestinations, TBLTPRates, TBLTPDestinationRates, TBLTPRatingPlans, TBLTPRateProfiles, TBLTPSharedGroups, TBLTPActions, TBLTPActionPlans, TBLTPActionTriggers, TBLTPAccountActions, TBLTPResources, TBLTPStats, TBLTPThresholds, TBLTPFilters, SessionCostsTBL, CDRsTBL, - TBLTPSuppliers, TBLTPAttributes, TBLTPChargers, TBLTPDispatchers, TBLTPDispatcherHosts}) + TBLTPRoutes, TBLTPAttributes, TBLTPChargers, TBLTPDispatchers, TBLTPDispatcherHosts}) // ProtectedSFlds are the fields that sessions should not alter ProtectedSFlds = NewStringSet([]string{CGRID, OriginHost, OriginID, Usage}) ) @@ -266,7 +266,7 @@ const ( CDR_STATS_PREFIX = "cst_" VERSION_PREFIX = "ver_" StatQueueProfilePrefix = "sqp_" - SupplierProfilePrefix = "spp_" + RouteProfilePrefix = "rpp_" AttributeProfilePrefix = "alp_" ChargerProfilePrefix = "cpp_" DispatcherProfilePrefix = "dpp_" @@ -650,6 +650,8 @@ const ( Preference = "Preference" Flags = "Flags" Service = "Service" + MetaRoutesLimit = "*routes_limit" + MetaRoutesOffset = "*routes_offset" ApierV = "ApierV" MetaApier = "*apier" MetaAnalyzer = "*analyzer" @@ -709,6 +711,10 @@ const ( MetaMSCHAPV2 = "*mschapv2" MetaDynaprepaid = "*dynaprepaid" MetaFD = "*fd" + SortingData = "SortingData" + Count = "Count" + ProfileID = "ProfileID" + SortedRoutes = "SortedRoutes" ) // Migrator Action @@ -729,14 +735,14 @@ const ( MetaStatQueueProfiles = "*statqueue_profiles" MetaStatQueues = "*statqueues" MetaThresholdProfiles = "*threshold_profiles" - MetaSupplierProfiles = "*supplier_profiles" + MetaRouteProfiles = "*route_profiles" MetaAttributeProfiles = "*attribute_profiles" MetaFilterIndexes = "*filter_indexes" MetaDispatcherProfiles = "*dispatcher_profiles" MetaChargerProfiles = "*charger_profiles" MetaSharedGroups = "*shared_groups" MetaThresholds = "*thresholds" - MetaSuppliers = "*suppliers" + MetaRoutes = "*routes" MetaAttributes = "*attributes" MetaLoadIDs = "*load_ids" ) @@ -781,7 +787,7 @@ const ( SessionsLow = "sessions" AttributesLow = "attributes" ChargerSLow = "chargers" - SuppliersLow = "suppliers" + RoutesLow = "suppliers" ResourcesLow = "resources" StatServiceLow = "stats" ThresholdsLow = "thresholds" @@ -842,7 +848,7 @@ const ( MetaTpActionPlans = "*tp_action_plans" MetaTpActions = "*tp_actions" MetaTpThresholds = "*tp_thresholds" - MetaTpSuppliers = "*tp_suppliers" + MetaTpRoutes = "*tp_Routes" MetaTpStats = "*tp_stats" MetaTpSharedGroups = "*tp_shared_groups" MetaTpRatingProfiles = "*tp_rating_profiles" @@ -858,7 +864,7 @@ const ( CapResourceMessage = "ResourceMessage" CapResourceAllocation = "ResourceAllocation" CapMaxUsage = "MaxUsage" - CapSuppliers = "Suppliers" + CapRoutes = "Routes" CapThresholds = "Thresholds" CapStatQueues = "StatQueues" ) @@ -872,7 +878,7 @@ const ( TpActionPlans = "TpActionPlans" TpActions = "TpActions" TpThresholds = "TpThresholds" - TpSuppliers = "TpSuppliers" + TpRoutes = "TpRoutes" TpStats = "TpStats" TpSharedGroups = "TpSharedGroups" TpRatingProfiles = "TpRatingProfiles" @@ -897,7 +903,7 @@ const ( ThresholdSv1 = "ThresholdSv1" StatSv1 = "StatSv1" ResourceSv1 = "ResourceSv1" - SupplierSv1 = "SupplierSv1" + RouteSv1 = "RouteSv1" AttributeSv1 = "AttributeSv1" SessionSv1 = "SessionSv1" ChargerSv1 = "ChargerSv1" @@ -1257,13 +1263,13 @@ const ( // SupplierS APIs const ( - SupplierSv1GetSuppliers = "SupplierSv1.GetSuppliers" - SupplierSv1GetSupplierProfilesForEvent = "SupplierSv1.GetSupplierProfilesForEvent" - SupplierSv1Ping = "SupplierSv1.Ping" - APIerSv1GetSupplierProfile = "APIerSv1.GetSupplierProfile" - APIerSv1GetSupplierProfileIDs = "APIerSv1.GetSupplierProfileIDs" - APIerSv1RemoveSupplierProfile = "APIerSv1.RemoveSupplierProfile" - APIerSv1SetSupplierProfile = "APIerSv1.SetSupplierProfile" + RouteSv1GetRoutes = "RouteSv1.GetRoutes" + RouteSv1GetRouteProfilesForEvent = "RouteSv1.GetRouteProfilesForEvent" + RouteSv1Ping = "RouteSv1.Ping" + APIerSv1GetRouteProfile = "APIerSv1.GetRouteProfile" + APIerSv1GetRouteProfileIDs = "APIerSv1.GetRouteProfileIDs" + APIerSv1RemoveRouteProfile = "APIerSv1.RemoveRouteProfile" + APIerSv1SetRouteProfile = "APIerSv1.SetRouteProfile" ) // AttributeS APIs @@ -1490,7 +1496,7 @@ const ( StatsCsv = "Stats.csv" ThresholdsCsv = "Thresholds.csv" FiltersCsv = "Filters.csv" - SuppliersCsv = "Suppliers.csv" + RoutesCsv = "Routes.csv" AttributesCsv = "Attributes.csv" ChargersCsv = "Chargers.csv" DispatcherProfilesCsv = "DispatcherProfiles.csv" @@ -1516,7 +1522,7 @@ const ( TBLTPFilters = "tp_filters" SessionCostsTBL = "session_costs" CDRsTBL = "cdrs" - TBLTPSuppliers = "tp_suppliers" + TBLTPRoutes = "tp_routes" TBLTPAttributes = "tp_attributes" TBLTPChargers = "tp_chargers" TBLVersions = "versions" @@ -1545,7 +1551,7 @@ const ( CacheThresholdProfiles = "*threshold_profiles" CacheThresholds = "*thresholds" CacheFilters = "*filters" - CacheSupplierProfiles = "*supplier_profiles" + CacheRouteProfiles = "*route_profiles" CacheAttributeProfiles = "*attribute_profiles" CacheChargerProfiles = "*charger_profiles" CacheDispatcherProfiles = "*dispatcher_profiles" @@ -1556,7 +1562,7 @@ const ( CacheResourceFilterIndexes = "*resource_filter_indexes" CacheStatFilterIndexes = "*stat_filter_indexes" CacheThresholdFilterIndexes = "*threshold_filter_indexes" - CacheSupplierFilterIndexes = "*supplier_filter_indexes" + CacheRouteFilterIndexes = "*route_filter_indexes" CacheAttributeFilterIndexes = "*attribute_filter_indexes" CacheChargerFilterIndexes = "*charger_filter_indexes" CacheDispatcherFilterIndexes = "*dispatcher_filter_indexes" @@ -1579,11 +1585,11 @@ const ( ResourceFilterIndexes = "rfi_" StatFilterIndexes = "sfi_" ThresholdFilterIndexes = "tfi_" - SupplierFilterIndexes = "spi_" AttributeFilterIndexes = "afi_" ChargerFilterIndexes = "cfi_" DispatcherFilterIndexes = "dfi_" ActionPlanIndexes = "api_" + RouteFilterIndexes = "rti_" ) // Agents @@ -1766,7 +1772,7 @@ const ( RALsConnsCfg = "rals_conns" ResSConnsCfg = "resources_conns" ThreshSConnsCfg = "thresholds_conns" - SupplSConnsCfg = "suppliers_conns" + RouteSConnsCfg = "routes_conns" AttrSConnsCfg = "attributes_conns" ReplicationConnsCfg = "replication_conns" DebitIntervalCfg = "debit_interval" @@ -2025,7 +2031,7 @@ const ( ResourceSCfg = "resources" // from JSON StatsCfg = "stats" // from JSON ThresholdSCfg = "thresholds" // from JSON - SupplierSCfg = "suppliers" // from JSON + RouteSCfg = "routes" // from JSON SureTaxCfg = "suretax" // from JSON DispatcherSCfg = "dispatchers" // from JSON LoaderCgrCfg = "loader" // from JSON