mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added scheduler_address to loader config params, fixes #19
This commit is contained in:
committed by
Dan Christian Bogos
parent
cf456ce64b
commit
c56d8633cb
@@ -86,6 +86,7 @@ var (
|
||||
rpcEncoding = flag.String("rpc_encoding", utils.MetaJSONrpc, "RPC encoding used <gob|json>")
|
||||
cacheSAddress = flag.String("caches_address", dfltCfg.LoaderCgrConfig.CachesConns[0].Address,
|
||||
"CacheS component to contact for cache reloads, empty to disable automatic cache reloads")
|
||||
schedulerAddress = flag.String("scheduler_address", dfltCfg.LoaderCgrConfig.SchedulerConns[0].Address, "")
|
||||
|
||||
importID = flag.String("import_id", "", "Uniquely identify an import/load, postpended to some automatic fields")
|
||||
timezone = flag.String("timezone", "", `Timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB>`)
|
||||
@@ -184,6 +185,14 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
if *schedulerAddress != dfltCfg.LoaderCgrConfig.SchedulerConns[0].Address {
|
||||
ldrCfg.LoaderCgrConfig.SchedulerConns = make([]*config.HaPoolConfig, 0)
|
||||
if *schedulerAddress != "" {
|
||||
ldrCfg.LoaderCgrConfig.SchedulerConns = append(ldrCfg.LoaderCgrConfig.SchedulerConns,
|
||||
&config.HaPoolConfig{Address: *schedulerAddress})
|
||||
}
|
||||
}
|
||||
|
||||
if *rpcEncoding != dfltCfg.LoaderCgrConfig.CachesConns[0].Transport &&
|
||||
len(ldrCfg.LoaderCgrConfig.CachesConns) != 0 {
|
||||
ldrCfg.LoaderCgrConfig.CachesConns[0].Transport = *rpcEncoding
|
||||
|
||||
@@ -109,8 +109,6 @@ func main() {
|
||||
|
||||
ldrCfg := config.CgrConfig()
|
||||
|
||||
//fmt.Printf("Before change: %+v \n \n", ldrCfg)
|
||||
|
||||
if *inDataDBType != dfltCfg.DataDbType {
|
||||
ldrCfg.DataDbType = *inDataDBType
|
||||
}
|
||||
@@ -163,8 +161,6 @@ func main() {
|
||||
ldrCfg.DBDataEncoding = *inDBDataEncoding
|
||||
}
|
||||
|
||||
//fmt.Printf("After change: %+v \n \n", ldrCfg)
|
||||
|
||||
if *outDataDBType == utils.MetaDynamic {
|
||||
*outDataDBType = ldrCfg.DataDbType
|
||||
*outDataDBHost = ldrCfg.DataDbHost
|
||||
|
||||
@@ -619,6 +619,9 @@ const CGRATES_CFG_JSON = `
|
||||
"caches_conns":[ // addresses towards cacheS components for reloads
|
||||
{"address": "127.0.0.1:2012", "transport": "*json"}
|
||||
],
|
||||
"scheduler_conns": [
|
||||
{"address": "127.0.0.1:2012"}
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -1249,10 +1249,17 @@ func TestDfLoaderCfg(t *testing.T) {
|
||||
Tpid: utils.StringPointer(""),
|
||||
Data_path: utils.StringPointer(""),
|
||||
Disable_reverse: utils.BoolPointer(false),
|
||||
Caches_conns: &[]*HaPoolJsonCfg{&HaPoolJsonCfg{
|
||||
Address: utils.StringPointer("127.0.0.1:2012"),
|
||||
Transport: utils.StringPointer(utils.MetaJSONrpc),
|
||||
}},
|
||||
Caches_conns: &[]*HaPoolJsonCfg{
|
||||
&HaPoolJsonCfg{
|
||||
Address: utils.StringPointer("127.0.0.1:2012"),
|
||||
Transport: utils.StringPointer(utils.MetaJSONrpc),
|
||||
},
|
||||
},
|
||||
Scheduler_conns: &[]*HaPoolJsonCfg{
|
||||
&HaPoolJsonCfg{
|
||||
Address: utils.StringPointer("127.0.0.1:2012"),
|
||||
},
|
||||
},
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.LoaderCfgJson(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -1276,6 +1276,11 @@ func TestCgrLoaderCfgDefault(t *testing.T) {
|
||||
Transport: utils.MetaJSONrpc,
|
||||
},
|
||||
},
|
||||
SchedulerConns: []*HaPoolConfig{
|
||||
&HaPoolConfig{
|
||||
Address: "127.0.0.1:2012",
|
||||
},
|
||||
},
|
||||
}
|
||||
if !reflect.DeepEqual(cgrCfg.LoaderCgrConfig, eLdrCfg) {
|
||||
t.Errorf("received: %+v, expecting: %+v", utils.ToJSON(cgrCfg.LoaderCgrConfig), utils.ToJSON(eLdrCfg))
|
||||
|
||||
@@ -496,4 +496,5 @@ type LoaderCfgJson struct {
|
||||
Data_path *string
|
||||
Disable_reverse *bool
|
||||
Caches_conns *[]*HaPoolJsonCfg
|
||||
Scheduler_conns *[]*HaPoolJsonCfg
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ type LoaderCgrCfg struct {
|
||||
DataPath string
|
||||
DisableReverse bool
|
||||
CachesConns []*HaPoolConfig
|
||||
SchedulerConns []*HaPoolConfig
|
||||
}
|
||||
|
||||
func (ld *LoaderCgrCfg) loadFromJsonCfg(jsnCfg *LoaderCfgJson) (err error) {
|
||||
@@ -42,5 +43,12 @@ func (ld *LoaderCgrCfg) loadFromJsonCfg(jsnCfg *LoaderCfgJson) (err error) {
|
||||
ld.CachesConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
}
|
||||
}
|
||||
if jsnCfg.Scheduler_conns != nil {
|
||||
ld.SchedulerConns = make([]*HaPoolConfig, len(*jsnCfg.Scheduler_conns))
|
||||
for idx, jsnScheHaCfg := range *jsnCfg.Scheduler_conns {
|
||||
ld.SchedulerConns[idx] = NewDfltHaPoolConfig()
|
||||
ld.SchedulerConns[idx].loadFromJsonCfg(jsnScheHaCfg)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user