From d60ac504b1899ee9fccadc83d4912541ea34e0b2 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Tue, 7 Jan 2020 18:02:03 +0200 Subject: [PATCH] Updated ConfigSv1.ReloadSections to ConfigSv1.ReloadConfigFromJSON --- apier/v1/config.go | 12 +- apier/v1/dispatcher.go | 8 +- apier/v1/dispatcher_interface.go | 3 +- cmd/cgr-engine/cgr-engine.go | 2 +- config/config.go | 449 +++++++++---------------------- config/config_it_test.go | 52 ++-- console/reload_config.go | 2 +- dispatchers/config.go | 28 +- engine/account_test.go | 19 +- ers/ers_reload_it_test.go | 6 +- services/attributes_it_test.go | 2 +- services/cdrs_it_test.go | 2 +- services/chargers_it_test.go | 2 +- services/datadb_it_test.go | 2 +- services/dispatchers_it_test.go | 2 +- services/dnsagent_it_test.go | 2 +- services/ers_it_test.go | 2 +- services/rals_it_test.go | 2 +- services/resources_it_test.go | 2 +- services/schedulers_it_test.go | 2 +- services/sessions_it_test.go | 2 +- services/stats_it_test.go | 2 +- services/suppliers_it_test.go | 2 +- services/thresholds_it_test.go | 2 +- utils/consts.go | 7 +- 25 files changed, 223 insertions(+), 393 deletions(-) diff --git a/apier/v1/config.go b/apier/v1/config.go index 7b3584760..f13c70824 100644 --- a/apier/v1/config.go +++ b/apier/v1/config.go @@ -38,14 +38,14 @@ func (cSv1 *ConfigSv1) GetJSONSection(section *config.StringWithArgDispatcher, r return cSv1.cfg.V1GetConfigSection(section, reply) } -// ReloadConfig reloads the configuration -func (cSv1 *ConfigSv1) ReloadConfig(args *config.ConfigReloadWithArgDispatcher, reply *string) (err error) { - return cSv1.cfg.V1ReloadConfig(args, reply) +// ReloadConfigFromPath reloads the configuration +func (cSv1 *ConfigSv1) ReloadConfigFromPath(args *config.ConfigReloadWithArgDispatcher, reply *string) (err error) { + return cSv1.cfg.V1ReloadConfigFromPath(args, reply) } -// ReloadSections reloads the sections of configz -func (cSv1 *ConfigSv1) ReloadSections(args map[string]interface{}, reply *string) (err error) { - return cSv1.cfg.V1ReloadSections(args, reply) +// ReloadConfigFromJSON reloads the sections of configz +func (cSv1 *ConfigSv1) ReloadConfigFromJSON(args *config.JSONReloadWithArgDispatcher, reply *string) (err error) { + return cSv1.cfg.V1ReloadConfigFromJSON(args, reply) } // Call implements rpcclient.ClientConnector interface for internal RPC diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index 10320ec30..2a95306f2 100755 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -767,8 +767,12 @@ func (dS *DispatcherConfigSv1) GetJSONSection(args *config.StringWithArgDispatch return dS.dS.ConfigSv1GetJSONSection(args, reply) } -func (dS *DispatcherConfigSv1) ReloadConfig(args *config.ConfigReloadWithArgDispatcher, reply *string) (err error) { - return dS.dS.ConfigSv1ReloadConfig(args, reply) +func (dS *DispatcherConfigSv1) ReloadConfigFromPath(args *config.ConfigReloadWithArgDispatcher, reply *string) (err error) { + return dS.dS.ConfigSv1ReloadConfigFromPath(args, reply) +} + +func (dS *DispatcherConfigSv1) ReloadConfigFromJSON(args *config.JSONReloadWithArgDispatcher, reply *string) (err error) { + return dS.dS.ConfigSv1ReloadConfigFromJSON(args, reply) } func NewDispatcherCoreSv1(dps *dispatchers.DispatcherService) *DispatcherCoreSv1 { diff --git a/apier/v1/dispatcher_interface.go b/apier/v1/dispatcher_interface.go index 2754bf56f..b0e78ed42 100644 --- a/apier/v1/dispatcher_interface.go +++ b/apier/v1/dispatcher_interface.go @@ -154,7 +154,8 @@ type RALsV1Interface interface { type ConfigSv1Interface interface { GetJSONSection(section *config.StringWithArgDispatcher, reply *map[string]interface{}) (err error) - ReloadConfig(section *config.ConfigReloadWithArgDispatcher, reply *string) (err error) + ReloadConfigFromPath(section *config.ConfigReloadWithArgDispatcher, reply *string) (err error) + ReloadConfigFromJSON(args *config.JSONReloadWithArgDispatcher, reply *string) (err error) } type CoreSv1Interface interface { diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index 6bacdfebd..54f82fcac 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -361,7 +361,7 @@ func singnalHandler(exitChan chan bool) { // do it in it's own gorutine in order to not block the signal handler with the reload functionality go func() { var reply string - if err := config.CgrConfig().V1ReloadConfig( + if err := config.CgrConfig().V1ReloadConfigFromPath( &config.ConfigReloadWithArgDispatcher{ Section: utils.EmptyString, Path: config.CgrConfig().ConfigPath, // use the same path diff --git a/config/config.go b/config/config.go index 3128f0701..425d7d5a8 100755 --- a/config/config.go +++ b/config/config.go @@ -1181,8 +1181,8 @@ func (cfg *CGRConfig) unlockSections() { } } -// V1ReloadConfig reloads the configuration -func (cfg *CGRConfig) V1ReloadConfig(args *ConfigReloadWithArgDispatcher, reply *string) (err error) { +// V1ReloadConfigFromPath reloads the configuration +func (cfg *CGRConfig) V1ReloadConfigFromPath(args *ConfigReloadWithArgDispatcher, reply *string) (err error) { if missing := utils.MissingStructFields(args, []string{"Path"}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } @@ -1446,307 +1446,65 @@ func (cfg *CGRConfig) reloadSection(section string) (err error) { return } +func (cfg *CGRConfig) getLoadFunctions() map[string]func(*CgrJsonCfg) error { + return map[string]func(*CgrJsonCfg) error{ + GENERAL_JSN: cfg.loadGeneralCfg, + DATADB_JSN: cfg.loadDataDBCfg, + STORDB_JSN: cfg.loadStorDBCfg, + LISTEN_JSN: cfg.loadListenCfg, + TlsCfgJson: cfg.loadTlsCgrCfg, + HTTP_JSN: cfg.loadHttpCfg, + SCHEDULER_JSN: cfg.loadSchedulerCfg, + CACHE_JSN: cfg.loadCacheCfg, + FilterSjsn: cfg.loadFilterSCfg, + RALS_JSN: cfg.loadRalSCfg, + CDRS_JSN: cfg.loadCdrsCfg, + CDRE_JSN: cfg.loadCdreCfg, + CDRC_JSN: cfg.loadCdrcCfg, + ERsJson: cfg.loadErsCfg, + SessionSJson: cfg.loadSessionSCfg, + AsteriskAgentJSN: cfg.loadAsteriskAgentCfg, + FreeSWITCHAgentJSN: cfg.loadFreeswitchAgentCfg, + KamailioAgentJSN: cfg.loadKamAgentCfg, + DA_JSN: cfg.loadDiameterAgentCfg, + RA_JSN: cfg.loadRadiusAgentCfg, + HttpAgentJson: cfg.loadHttpAgentCfg, + DNSAgentJson: cfg.loadDNSAgentCfg, + ATTRIBUTE_JSN: cfg.loadAttributeSCfg, + ChargerSCfgJson: cfg.loadChargerSCfg, + RESOURCES_JSON: cfg.loadResourceSCfg, + STATS_JSON: cfg.loadStatSCfg, + THRESHOLDS_JSON: cfg.loadThresholdSCfg, + SupplierSJson: cfg.loadSupplierSCfg, + LoaderJson: cfg.loadLoaderSCfg, + MAILER_JSN: cfg.loadMailerCfg, + SURETAX_JSON: cfg.loadSureTaxCfg, + CgrLoaderCfgJson: cfg.loadLoaderCgrCfg, + CgrMigratorCfgJson: cfg.loadMigratorCgrCfg, + DispatcherSJson: cfg.loadDispatcherSCfg, + AnalyzerCfgJson: cfg.loadAnalyzerCgrCfg, + Apier: cfg.loadApierCfg, + RPCConnsJsonName: cfg.loadRPCConns, + } +} func (cfg *CGRConfig) loadConfig(path, section string) (err error) { var loadFuncs []func(*CgrJsonCfg) error - var fall bool - switch section { - default: + loadMap := cfg.getLoadFunctions() + if section == utils.EmptyString || section == utils.MetaAll { + for _, sec := range []string{GENERAL_JSN, RPCConnsJsonName, DATADB_JSN, STORDB_JSN, LISTEN_JSN, TlsCfgJson, HTTP_JSN, SCHEDULER_JSN, CACHE_JSN, FilterSjsn, RALS_JSN, + CDRS_JSN, CDRE_JSN, CDRC_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, Apier} { + cfg.lks[sec].Lock() + defer cfg.lks[sec].Unlock() + loadFuncs = append(loadFuncs, loadMap[sec]) + } + } else if fnct, has := loadMap[section]; !has { return fmt.Errorf("Invalid section: <%s>", section) - case utils.EmptyString, utils.MetaAll: - fall = true - fallthrough - case GENERAL_JSN: - cfg.lks[GENERAL_JSN].Lock() - defer cfg.lks[GENERAL_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadGeneralCfg) - if !fall { - break - } - fallthrough - case DATADB_JSN: - cfg.lks[DATADB_JSN].Lock() - defer cfg.lks[DATADB_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadDataDBCfg) - if !fall { - break - } - fallthrough - case STORDB_JSN: - cfg.lks[STORDB_JSN].Lock() - defer cfg.lks[STORDB_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadStorDBCfg) - if !fall { - break - } - fallthrough - case LISTEN_JSN: - cfg.lks[LISTEN_JSN].Lock() - defer cfg.lks[LISTEN_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadListenCfg) - if !fall { - break - } - fallthrough - case TlsCfgJson: - cfg.lks[TlsCfgJson].Lock() - defer cfg.lks[TlsCfgJson].Unlock() - loadFuncs = append(loadFuncs, cfg.loadTlsCgrCfg) - if !fall { - break - } - fallthrough - case HTTP_JSN: - cfg.lks[HTTP_JSN].Lock() - defer cfg.lks[HTTP_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadHttpCfg) - if !fall { - break - } - fallthrough - case SCHEDULER_JSN: - cfg.lks[SCHEDULER_JSN].Lock() - defer cfg.lks[SCHEDULER_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadSchedulerCfg) - if !fall { - break - } - fallthrough - case CACHE_JSN: - cfg.lks[CACHE_JSN].Lock() - defer cfg.lks[CACHE_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadCacheCfg) - if !fall { - break - } - fallthrough - case FilterSjsn: - cfg.lks[FilterSjsn].Lock() - defer cfg.lks[FilterSjsn].Unlock() - loadFuncs = append(loadFuncs, cfg.loadFilterSCfg) - if !fall { - break - } - fallthrough - case RALS_JSN: - cfg.lks[RALS_JSN].Lock() - defer cfg.lks[RALS_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadRalSCfg) - if !fall { - break - } - fallthrough - case CDRS_JSN: - cfg.lks[CDRS_JSN].Lock() - defer cfg.lks[CDRS_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadCdrsCfg) - if !fall { - break - } - fallthrough - case CDRE_JSN: - cfg.lks[CDRE_JSN].Lock() - defer cfg.lks[CDRE_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadCdreCfg) - if !fall { - break - } - fallthrough - case CDRC_JSN: - cfg.lks[CDRC_JSN].Lock() - defer cfg.lks[CDRC_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadCdrcCfg) - if !fall { - break - } - fallthrough - case ERsJson: - cfg.lks[ERsJson].Lock() - defer cfg.lks[ERsJson].Unlock() - loadFuncs = append(loadFuncs, cfg.loadErsCfg) - if !fall { - break - } - fallthrough - case SessionSJson: - cfg.lks[SessionSJson].Lock() - defer cfg.lks[SessionSJson].Unlock() - loadFuncs = append(loadFuncs, cfg.loadSessionSCfg) - if !fall { - break - } - fallthrough - case AsteriskAgentJSN: - cfg.lks[AsteriskAgentJSN].Lock() - defer cfg.lks[AsteriskAgentJSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadAsteriskAgentCfg) - if !fall { - break - } - fallthrough - case FreeSWITCHAgentJSN: - cfg.lks[FreeSWITCHAgentJSN].Lock() - defer cfg.lks[FreeSWITCHAgentJSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadFreeswitchAgentCfg) - if !fall { - break - } - fallthrough - case KamailioAgentJSN: - cfg.lks[KamailioAgentJSN].Lock() - defer cfg.lks[KamailioAgentJSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadKamAgentCfg) - if !fall { - break - } - fallthrough - case DA_JSN: - cfg.lks[DA_JSN].Lock() - defer cfg.lks[DA_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadDiameterAgentCfg) - if !fall { - break - } - fallthrough - case RA_JSN: - cfg.lks[RA_JSN].Lock() - defer cfg.lks[RA_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadRadiusAgentCfg) - if !fall { - break - } - fallthrough - case HttpAgentJson: - cfg.lks[HttpAgentJson].Lock() - defer cfg.lks[HttpAgentJson].Unlock() - loadFuncs = append(loadFuncs, cfg.loadHttpAgentCfg) - if !fall { - break - } - fallthrough - case DNSAgentJson: - cfg.lks[DNSAgentJson].Lock() - defer cfg.lks[DNSAgentJson].Unlock() - loadFuncs = append(loadFuncs, cfg.loadDNSAgentCfg) - if !fall { - break - } - fallthrough - case ATTRIBUTE_JSN: - cfg.lks[ATTRIBUTE_JSN].Lock() - defer cfg.lks[ATTRIBUTE_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadAttributeSCfg) - if !fall { - break - } - fallthrough - case ChargerSCfgJson: - cfg.lks[ChargerSCfgJson].Lock() - defer cfg.lks[ChargerSCfgJson].Unlock() - loadFuncs = append(loadFuncs, cfg.loadChargerSCfg) - if !fall { - break - } - fallthrough - case RESOURCES_JSON: - cfg.lks[RESOURCES_JSON].Lock() - defer cfg.lks[RESOURCES_JSON].Unlock() - loadFuncs = append(loadFuncs, cfg.loadResourceSCfg) - if !fall { - break - } - fallthrough - case STATS_JSON: - cfg.lks[STATS_JSON].Lock() - defer cfg.lks[STATS_JSON].Unlock() - loadFuncs = append(loadFuncs, cfg.loadStatSCfg) - if !fall { - break - } - fallthrough - case THRESHOLDS_JSON: - cfg.lks[THRESHOLDS_JSON].Lock() - defer cfg.lks[THRESHOLDS_JSON].Unlock() - loadFuncs = append(loadFuncs, cfg.loadThresholdSCfg) - if !fall { - break - } - fallthrough - case SupplierSJson: - cfg.lks[SupplierSJson].Lock() - defer cfg.lks[SupplierSJson].Unlock() - loadFuncs = append(loadFuncs, cfg.loadSupplierSCfg) - if !fall { - break - } - fallthrough - case LoaderJson: - cfg.lks[LoaderJson].Lock() - defer cfg.lks[LoaderJson].Unlock() - loadFuncs = append(loadFuncs, cfg.loadLoaderSCfg) - if !fall { - break - } - fallthrough - case MAILER_JSN: - cfg.lks[MAILER_JSN].Lock() - defer cfg.lks[MAILER_JSN].Unlock() - loadFuncs = append(loadFuncs, cfg.loadMailerCfg) - if !fall { - break - } - fallthrough - case SURETAX_JSON: - cfg.lks[SURETAX_JSON].Lock() - defer cfg.lks[SURETAX_JSON].Unlock() - loadFuncs = append(loadFuncs, cfg.loadSureTaxCfg) - if !fall { - break - } - fallthrough - case CgrLoaderCfgJson: - cfg.lks[CgrLoaderCfgJson].Lock() - defer cfg.lks[CgrLoaderCfgJson].Unlock() - loadFuncs = append(loadFuncs, cfg.loadLoaderCgrCfg) - if !fall { - break - } - fallthrough - case CgrMigratorCfgJson: - cfg.lks[CgrMigratorCfgJson].Lock() - defer cfg.lks[CgrMigratorCfgJson].Unlock() - loadFuncs = append(loadFuncs, cfg.loadMigratorCgrCfg) - if !fall { - break - } - fallthrough - case DispatcherSJson: - cfg.lks[DispatcherSJson].Lock() - defer cfg.lks[DispatcherSJson].Unlock() - loadFuncs = append(loadFuncs, cfg.loadDispatcherSCfg) - if !fall { - break - } - fallthrough - case AnalyzerCfgJson: - cfg.lks[AnalyzerCfgJson].Lock() - defer cfg.lks[AnalyzerCfgJson].Unlock() - loadFuncs = append(loadFuncs, cfg.loadAnalyzerCgrCfg) - if !fall { - break - } - fallthrough - case Apier: - cfg.lks[Apier].Lock() - defer cfg.lks[Apier].Unlock() - loadFuncs = append(loadFuncs, cfg.loadApierCfg) - if !fall { - break - } - fallthrough - case RPCConnsJsonName: - cfg.lks[RPCConnsJsonName].Lock() - defer cfg.lks[RPCConnsJsonName].Unlock() - loadFuncs = append(loadFuncs, cfg.loadRPCConns) + } else { + cfg.lks[section].Lock() + defer cfg.lks[section].Unlock() + loadFuncs = append(loadFuncs, fnct) } return cfg.loadConfigFromPath(path, loadFuncs) } @@ -1854,56 +1612,99 @@ func (cfg *CGRConfig) loadConfigFromHTTP(urlPaths string, loadFuncs []func(jsnCf func (cfg *CGRConfig) initChanels() { cfg.lks = make(map[string]*sync.RWMutex) cfg.rldChans = make(map[string]chan struct{}) - for _, section := range []string{GENERAL_JSN, DATADB_JSN, STORDB_JSN, LISTEN_JSN, TlsCfgJson, HTTP_JSN, SCHEDULER_JSN, CACHE_JSN, FilterSjsn, RALS_JSN, + for _, section := range []string{GENERAL_JSN, RPCConnsJsonName, DATADB_JSN, STORDB_JSN, LISTEN_JSN, TlsCfgJson, HTTP_JSN, SCHEDULER_JSN, CACHE_JSN, FilterSjsn, RALS_JSN, CDRS_JSN, CDRE_JSN, CDRC_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, Apier, RPCConnsJsonName} { + SupplierSJson, LoaderJson, MAILER_JSN, SURETAX_JSON, CgrLoaderCfgJson, CgrMigratorCfgJson, DispatcherSJson, AnalyzerCfgJson, Apier} { cfg.lks[section] = new(sync.RWMutex) cfg.rldChans[section] = make(chan struct{}, 1) } } -// V1ReloadSections reloads the sections of configz -func (cfg *CGRConfig) V1ReloadSections(args map[string]interface{}, reply *string) (err error) { - if len(args) == 0 { +// JSONReloadWithArgDispatcher the API params for V1ReloadConfigFromJSON +type JSONReloadWithArgDispatcher struct { + *utils.ArgDispatcher + utils.TenantArg + JSON map[string]interface{} +} + +// V1ReloadConfigFromJSON reloads the sections of configz +func (cfg *CGRConfig) V1ReloadConfigFromJSON(args *JSONReloadWithArgDispatcher, reply *string) (err error) { + if len(args.JSON) == 0 { *reply = utils.OK return } + sections := make([]string, 0, len(args.JSON)) + for section := range args.JSON { + sections = append(sections, section) + } + var b []byte - if b, err = json.Marshal(args); err != nil { + if b, err = json.Marshal(args.JSON); err != nil { return } - fmt.Println(string(b)) + + if err = cfg.loadConfigFromJSON(bytes.NewBuffer(b), sections); err != nil { + return + } + // lock all sections - cfg.lockSections() - fmt.Println("lock") + cfg.rLockSections() - if err = cfg.loadConfigFromReader(bytes.NewBuffer(b), []func(*CgrJsonCfg) error{cfg.loadFromJsonCfg}); err != nil { - cfg.unlockSections() // unlock before exiting function - return - } - - fmt.Println("before checkConfigSanity") err = cfg.checkConfigSanity() - fmt.Println("after checkConfigSanity") - cfg.unlockSections() // unlock before checking the error - fmt.Println("after unlock") + cfg.rUnlockSections() // unlock before checking the error if err != nil { return } - section := utils.MetaAll - if len(args) == 1 { - for k := range args { - section = k + 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}) + needsDataDB := false + for _, section := range sections { + if subsystemsThatNeedDataDB.Has(section) { + needsDataDB = true + cfg.rldChans[DATADB_JSN] <- struct{}{} // reload datadb before break } } - if err = cfg.reloadSection(section); err != nil { - return + subsystemsThatNeedStorDB := utils.NewStringSet([]string{STORDB_JSN, RALS_JSN, CDRS_JSN, Apier}) + needsStorDB := false + for _, section := range sections { + if subsystemsThatNeedStorDB.Has(section) { + needsStorDB = true + cfg.rldChans[STORDB_JSN] <- struct{}{} // reload datadb before + break + } + } + time.Sleep(1) + for _, section := range sections { + if needsDataDB && section == DATADB_JSN { + continue + } + if needsStorDB && section == STORDB_JSN { + continue + } + cfg.rldChans[section] <- struct{}{} } *reply = utils.OK return } + +func (cfg *CGRConfig) loadConfigFromJSON(rdr io.Reader, sections []string) (err error) { + var loadFuncs []func(*CgrJsonCfg) error + loadMap := cfg.getLoadFunctions() + for _, section := range sections { + if fnct, has := loadMap[section]; !has { + return fmt.Errorf("Invalid section: <%s>", section) + } else { + cfg.lks[section].Lock() + defer cfg.lks[section].Unlock() + loadFuncs = append(loadFuncs, fnct) + } + } + return cfg.loadConfigFromReader(rdr, loadFuncs) +} diff --git a/config/config_it_test.go b/config/config_it_test.go index 0c5b940c0..fad8c0834 100644 --- a/config/config_it_test.go +++ b/config/config_it_test.go @@ -87,7 +87,7 @@ func TestCGRConfigReloadAttributeS(t *testing.T) { t.Fatal(err) } var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), Section: ATTRIBUTE_JSN, }, &reply); err != nil { @@ -113,7 +113,7 @@ func TestCGRConfigReloadChargerS(t *testing.T) { t.Fatal(err) } var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), Section: ChargerSCfgJson, }, &reply); err != nil { @@ -139,7 +139,7 @@ func TestCGRConfigReloadThresholdS(t *testing.T) { t.Fatal(err) } var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), Section: THRESHOLDS_JSON, }, &reply); err != nil { @@ -164,7 +164,7 @@ func TestCGRConfigReloadStatS(t *testing.T) { t.Fatal(err) } var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), Section: STATS_JSON, }, &reply); err != nil { @@ -190,7 +190,7 @@ func TestCGRConfigReloadResourceS(t *testing.T) { t.Fatal(err) } var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), Section: RESOURCES_JSON, }, &reply); err != nil { @@ -216,7 +216,7 @@ func TestCGRConfigReloadSupplierS(t *testing.T) { t.Fatal(err) } var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), Section: SupplierSJson, }, &reply); err != nil { @@ -245,7 +245,7 @@ func TestCGRConfigReloadSchedulerS(t *testing.T) { t.Fatal(err) } var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), Section: SCHEDULER_JSN, }, &reply); err != nil { @@ -270,7 +270,7 @@ func TestCGRConfigReloadCDRs(t *testing.T) { } cfg.RalsCfg().Enabled = true var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), Section: CDRS_JSN, }, &reply); err != nil { @@ -306,7 +306,7 @@ func TestCGRConfigReloadRALs(t *testing.T) { blMap := cfg.RalsCfg().BalanceRatingSubject maxComp := cfg.RalsCfg().MaxComputedUsage var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), Section: RALS_JSN, }, &reply); err != nil { @@ -338,7 +338,7 @@ func TestCGRConfigReloadSessionS(t *testing.T) { cfg.ChargerSCfg().Enabled = true cfg.CdrsCfg().Enabled = true var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), Section: SessionSJson, }, &reply); err != nil { @@ -385,7 +385,7 @@ func TestCGRConfigReloadERs(t *testing.T) { } cfg.SessionSCfg().Enabled = true var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "ers_example"), Section: ERsJson, }, &reply); err != nil { @@ -453,7 +453,7 @@ func TestCGRConfigReloadDNSAgent(t *testing.T) { } cfg.SessionSCfg().Enabled = true var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "dnsagent_reload"), Section: DNSAgentJson, }, &reply); err != nil { @@ -481,7 +481,7 @@ func TestCGRConfigReloadFreeswitchAgent(t *testing.T) { } cfg.SessionSCfg().Enabled = true var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "freeswitch_reload"), Section: FreeSWITCHAgentJSN, }, &reply); err != nil { @@ -855,7 +855,7 @@ func TestCgrCfgV1ReloadConfigSection(t *testing.T) { var reply string var rcv map[string]interface{} - if err := cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err := cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: "/usr/share/cgrates/conf/samples/ers_example", Section: ERsJson, }, &reply); err != nil { @@ -877,7 +877,7 @@ func TestCgrCfgV1ReloadConfigSection(t *testing.T) { } } -func TestCGRConfigReloadSectionsSessionS(t *testing.T) { +func TestCGRConfigReloadConfigFromJSONSessionS(t *testing.T) { cfg, err := NewDefaultCGRConfig() if err != nil { t.Fatal(err) @@ -886,15 +886,17 @@ func TestCGRConfigReloadSectionsSessionS(t *testing.T) { cfg.ChargerSCfg().Enabled = true cfg.CdrsCfg().Enabled = true var reply string - if err = cfg.V1ReloadSections(map[string]interface{}{ - "sessions": map[string]interface{}{ - "enabled": true, - "resources_conns": []string{"*localhost"}, - "suppliers_conns": []string{"*localhost"}, - "attributes_conns": []string{"*localhost"}, - "rals_conns": []string{"*internal"}, - "cdrs_conns": []string{"*internal"}, - "chargers_conns": []string{"*internal"}, + if err = cfg.V1ReloadConfigFromJSON(&JSONReloadWithArgDispatcher{ + JSON: map[string]interface{}{ + "sessions": map[string]interface{}{ + "enabled": true, + "resources_conns": []string{"*localhost"}, + "suppliers_conns": []string{"*localhost"}, + "attributes_conns": []string{"*localhost"}, + "rals_conns": []string{"*internal"}, + "cdrs_conns": []string{"*internal"}, + "chargers_conns": []string{"*internal"}, + }, }, }, &reply); err != nil { t.Error(err) @@ -933,7 +935,7 @@ func TestCGRConfigReloadAll(t *testing.T) { cfg.ChargerSCfg().Enabled = true cfg.CdrsCfg().Enabled = true var reply string - if err = cfg.V1ReloadConfig(&ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo2"), Section: utils.MetaAll, }, &reply); err != nil { diff --git a/console/reload_config.go b/console/reload_config.go index a2b67c40c..8ac88fcfb 100644 --- a/console/reload_config.go +++ b/console/reload_config.go @@ -26,7 +26,7 @@ import ( func init() { c := &CmdRelaodConfigSection{ name: "reload_config", - rpcMethod: utils.ConfigSv1ReloadConfig, + rpcMethod: utils.ConfigSv1ReloadConfigFromPath, rpcParams: &config.ConfigReloadWithArgDispatcher{}, } commands[c.Name()] = c diff --git a/dispatchers/config.go b/dispatchers/config.go index f710f0421..498c59e04 100644 --- a/dispatchers/config.go +++ b/dispatchers/config.go @@ -47,7 +47,7 @@ func (dS *DispatcherService) ConfigSv1GetJSONSection(args *config.StringWithArgD utils.MetaConfig, routeID, utils.ConfigSv1GetJSONSection, args, reply) } -func (dS *DispatcherService) ConfigSv1ReloadConfig(args *config.ConfigReloadWithArgDispatcher, reply *string) (err error) { +func (dS *DispatcherService) ConfigSv1ReloadConfigFromPath(args *config.ConfigReloadWithArgDispatcher, reply *string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.TenantArg.Tenant != utils.EmptyString { tnt = args.TenantArg.Tenant @@ -56,7 +56,7 @@ func (dS *DispatcherService) ConfigSv1ReloadConfig(args *config.ConfigReloadWith if args.ArgDispatcher == nil { return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField) } - if err = dS.authorize(utils.ConfigSv1ReloadConfig, tnt, + if err = dS.authorize(utils.ConfigSv1ReloadConfigFromPath, tnt, args.APIKey, utils.TimePointer(time.Now())); err != nil { return } @@ -66,5 +66,27 @@ func (dS *DispatcherService) ConfigSv1ReloadConfig(args *config.ConfigReloadWith routeID = args.ArgDispatcher.RouteID } return dS.Dispatch(&utils.CGREvent{Tenant: tnt}, - utils.MetaConfig, routeID, utils.ConfigSv1ReloadConfig, args, reply) + utils.MetaConfig, routeID, utils.ConfigSv1ReloadConfigFromPath, args, reply) +} + +func (dS *DispatcherService) ConfigSv1ReloadConfigFromJSON(args *config.JSONReloadWithArgDispatcher, reply *string) (err error) { + tnt := dS.cfg.GeneralCfg().DefaultTenant + if args.TenantArg.Tenant != utils.EmptyString { + tnt = args.TenantArg.Tenant + } + if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { + if args.ArgDispatcher == nil { + return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField) + } + if err = dS.authorize(utils.ConfigSv1ReloadConfigFromJSON, tnt, + args.APIKey, utils.TimePointer(time.Now())); err != nil { + return + } + } + var routeID *string + if args.ArgDispatcher != nil { + routeID = args.ArgDispatcher.RouteID + } + return dS.Dispatch(&utils.CGREvent{Tenant: tnt}, + utils.MetaConfig, routeID, utils.ConfigSv1ReloadConfigFromJSON, args, reply) } diff --git a/engine/account_test.go b/engine/account_test.go index e3de1b7fb..9b0a70004 100644 --- a/engine/account_test.go +++ b/engine/account_test.go @@ -2370,25 +2370,24 @@ func TestAccountClone(t *testing.T) { } -func TestAccountGetBalanceWithID(t *testing.T){ +func TestAccountGetBalanceWithID(t *testing.T) { account := &Account{ BalanceMap: map[string]Balances{ - "type1" : Balances{&Balance{ID: "test1",Value: 0.7,}}, - "type2" :Balances{&Balance{ID: "test2",Value: 0.8,}}, + "type1": Balances{&Balance{ID: "test1", Value: 0.7}}, + "type2": Balances{&Balance{ID: "test2", Value: 0.8}}, }, } - if rcv := account.GetBalanceWithID("type1","test1"); rcv.Value != 0.7{ - t.Errorf("Expecting: 0.7, received: %+v",rcv) + if rcv := account.GetBalanceWithID("type1", "test1"); rcv.Value != 0.7 { + t.Errorf("Expecting: 0.7, received: %+v", rcv) } - if rcv := account.GetBalanceWithID("type2","test2"); rcv.Value != 0.8{ - t.Errorf("Expecting: 0.8, received: %+v",rcv) + if rcv := account.GetBalanceWithID("type2", "test2"); rcv.Value != 0.8 { + t.Errorf("Expecting: 0.8, received: %+v", rcv) } - if rcv := account.GetBalanceWithID("unknown","unknown"); rcv != nil{ - t.Errorf("Expecting: nil, received: %+v",rcv) + if rcv := account.GetBalanceWithID("unknown", "unknown"); rcv != nil { + t.Errorf("Expecting: nil, received: %+v", rcv) } } - /*********************************** Benchmarks *******************************/ func BenchmarkGetSecondForPrefix(b *testing.B) { diff --git a/ers/ers_reload_it_test.go b/ers/ers_reload_it_test.go index f24281f07..9fd2106bb 100644 --- a/ers/ers_reload_it_test.go +++ b/ers/ers_reload_it_test.go @@ -45,7 +45,7 @@ var ( testReloadITStartEngine, testReloadITRpcConn, testReloadVerifyDisabledReaders, - testReloadReloadConfig, + testReloadReloadConfigFromPath, testReloadVerifyFirstReload, testReloadITKillEngine, } @@ -126,9 +126,9 @@ func testReloadVerifyDisabledReaders(t *testing.T) { } } -func testReloadReloadConfig(t *testing.T) { +func testReloadReloadConfigFromPath(t *testing.T) { var reply string - if err := reloadRPC.Call(utils.ConfigSv1ReloadConfig, &config.ConfigReloadWithArgDispatcher{ + if err := reloadRPC.Call(utils.ConfigSv1ReloadConfigFromPath, &config.ConfigReloadWithArgDispatcher{ Path: path.Join(*dataDir, "conf", "samples", "ers_reload", "first_reload"), Section: config.ERsJson, }, &reply); err != nil { diff --git a/services/attributes_it_test.go b/services/attributes_it_test.go index db00cf62e..01f1b8bcf 100644 --- a/services/attributes_it_test.go +++ b/services/attributes_it_test.go @@ -66,7 +66,7 @@ func TestAttributeSReload(t *testing.T) { } var reply string - if err := cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err := cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo"), Section: config.ATTRIBUTE_JSN, }, &reply); err != nil { diff --git a/services/cdrs_it_test.go b/services/cdrs_it_test.go index 99f73e96a..b1f166e19 100644 --- a/services/cdrs_it_test.go +++ b/services/cdrs_it_test.go @@ -96,7 +96,7 @@ func TestCdrsReload(t *testing.T) { t.Errorf("Expected service to be down") } var reply string - if err := cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err := cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo"), Section: config.CDRS_JSN, }, &reply); err != nil { diff --git a/services/chargers_it_test.go b/services/chargers_it_test.go index a04feaf42..5fb8741ef 100644 --- a/services/chargers_it_test.go +++ b/services/chargers_it_test.go @@ -67,7 +67,7 @@ func TestChargerSReload(t *testing.T) { t.Errorf("Expected service to be down") } var reply string - if err = cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo"), Section: config.ChargerSCfgJson, }, &reply); err != nil { diff --git a/services/datadb_it_test.go b/services/datadb_it_test.go index d41da668d..be1a21d3e 100644 --- a/services/datadb_it_test.go +++ b/services/datadb_it_test.go @@ -62,7 +62,7 @@ func TestDataDBReload(t *testing.T) { } var reply string cfg.AttributeSCfg().Enabled = true - if err := cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err := cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo"), Section: config.DATADB_JSN, }, &reply); err != nil { diff --git a/services/dispatchers_it_test.go b/services/dispatchers_it_test.go index b09fa9545..cb424ee1d 100644 --- a/services/dispatchers_it_test.go +++ b/services/dispatchers_it_test.go @@ -69,7 +69,7 @@ func TestDispatcherSReload(t *testing.T) { t.Errorf("Expected service to be down") } var reply string - if err = cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "dispatchers", "dispatchers"), Section: config.DispatcherSJson, }, &reply); err != nil { diff --git a/services/dnsagent_it_test.go b/services/dnsagent_it_test.go index 926293d6d..66a2a40b6 100644 --- a/services/dnsagent_it_test.go +++ b/services/dnsagent_it_test.go @@ -63,7 +63,7 @@ func TestDNSAgentReload(t *testing.T) { t.Errorf("Expected service to be down") } var reply string - if err := cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err := cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "dnsagent_reload"), Section: config.DNSAgentJson, }, &reply); err != nil { diff --git a/services/ers_it_test.go b/services/ers_it_test.go index 5fbb69c87..70b89361d 100644 --- a/services/ers_it_test.go +++ b/services/ers_it_test.go @@ -67,7 +67,7 @@ func TestEventReaderSReload(t *testing.T) { t.Errorf("Expected service to be down") } var reply string - if err := cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err := cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "ers_reload", "internal"), Section: config.ERsJson, }, &reply); err != nil { diff --git a/services/rals_it_test.go b/services/rals_it_test.go index a767d55cf..5f7a3c388 100644 --- a/services/rals_it_test.go +++ b/services/rals_it_test.go @@ -91,7 +91,7 @@ func TestRalsReload(t *testing.T) { t.Errorf("Expected service to be down") } var reply string - if err := cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err := cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo"), Section: config.RALS_JSN, }, &reply); err != nil { diff --git a/services/resources_it_test.go b/services/resources_it_test.go index 4adff2821..8b8df892b 100644 --- a/services/resources_it_test.go +++ b/services/resources_it_test.go @@ -69,7 +69,7 @@ func TestResourceSReload(t *testing.T) { t.Errorf("Expected service to be down") } var reply string - if err = cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo"), Section: config.RESOURCES_JSON, }, &reply); err != nil { diff --git a/services/schedulers_it_test.go b/services/schedulers_it_test.go index ab9edfbe8..1ca552dcb 100644 --- a/services/schedulers_it_test.go +++ b/services/schedulers_it_test.go @@ -60,7 +60,7 @@ func TestSchedulerSReload(t *testing.T) { t.Errorf("Expected service to be down") } var reply string - if err := cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err := cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongonew"), Section: config.SCHEDULER_JSN, }, &reply); err != nil { diff --git a/services/sessions_it_test.go b/services/sessions_it_test.go index a89d94e77..142d6e6eb 100644 --- a/services/sessions_it_test.go +++ b/services/sessions_it_test.go @@ -96,7 +96,7 @@ func TestSessionSReload(t *testing.T) { t.Errorf("Expected service to be down") } var reply string - if err := cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err := cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongonew"), Section: config.SessionSJson, }, &reply); err != nil { diff --git a/services/stats_it_test.go b/services/stats_it_test.go index 776a01f71..3a36da036 100644 --- a/services/stats_it_test.go +++ b/services/stats_it_test.go @@ -69,7 +69,7 @@ func TestStatSReload(t *testing.T) { t.Errorf("Expected service to be down") } var reply string - if err = cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo"), Section: config.STATS_JSON, }, &reply); err != nil { diff --git a/services/suppliers_it_test.go b/services/suppliers_it_test.go index 9ede9f206..6a8c64b79 100644 --- a/services/suppliers_it_test.go +++ b/services/suppliers_it_test.go @@ -67,7 +67,7 @@ func TestSupplierSReload(t *testing.T) { t.Errorf("Expected service to be down") } var reply string - if err := cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err := cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongonew"), Section: config.SupplierSJson, }, &reply); err != nil { diff --git a/services/thresholds_it_test.go b/services/thresholds_it_test.go index 7d4e6632f..57133bf3a 100644 --- a/services/thresholds_it_test.go +++ b/services/thresholds_it_test.go @@ -63,7 +63,7 @@ func TestThresholdSReload(t *testing.T) { t.Errorf("Expected service to be down") } var reply string - if err = cfg.V1ReloadConfig(&config.ConfigReloadWithArgDispatcher{ + if err = cfg.V1ReloadConfigFromPath(&config.ConfigReloadWithArgDispatcher{ Path: path.Join("/usr", "share", "cgrates", "conf", "samples", "tutmongo"), Section: config.THRESHOLDS_JSON, }, &reply); err != nil { diff --git a/utils/consts.go b/utils/consts.go index 783f3dd11..53a81b366 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -1178,9 +1178,10 @@ const ( ) const ( - ConfigSv1 = "ConfigSv1" - ConfigSv1GetJSONSection = "ConfigSv1.GetJSONSection" - ConfigSv1ReloadConfig = "ConfigSv1.ReloadConfig" + ConfigSv1 = "ConfigSv1" + ConfigSv1GetJSONSection = "ConfigSv1.GetJSONSection" + ConfigSv1ReloadConfigFromPath = "ConfigSv1.ReloadConfigFromPath" + ConfigSv1ReloadConfigFromJSON = "ConfigSv1.ReloadConfigFromJSON" ) const (