Adding CDRStatsConns to SMKamailio config

This commit is contained in:
DanB
2017-05-07 18:30:49 +02:00
parent 74488eeede
commit ee210a3cc5
5 changed files with 14 additions and 3 deletions

View File

@@ -135,7 +135,7 @@ const CGRATES_CFG_JSON = `
"pubsubs_conns": [], // address where to reach the pubusb service, empty to disable pubsub functionality: <""|*internal|x.y.z.y:1234>
"users_conns": [], // address where to reach the user service, empty to disable user profile functionality: <""|*internal|x.y.z.y:1234>
"aliases_conns": [], // address where to reach the aliases service, empty to disable aliases functionality: <""|*internal|x.y.z.y:1234>
"cdrstats_conns": [], // address where to reach the cdrstats service, empty to disable stats functionality<""|*internal|x.y.z.y:1234>
"cdrstats_conns": [], // address where to reach the cdrstats service, empty to disable stats functionality: <""|*internal|x.y.z.y:1234>
"online_cdr_exports":[], // list of CDRE profiles to use for real-time CDR exports
},
@@ -306,6 +306,7 @@ const CGRATES_CFG_JSON = `
"cdrs_conns": [
{"address": "*internal"} // address where to reach CDR Server, empty to disable CDR capturing <*internal|x.y.z.y:1234>
],
"cdrstats_conns": [], // address where to reach the cdrstats service, empty to disable stats functionality: <""|*internal|x.y.z.y:1234>
"create_cdr": false, // create CDR out of events and sends them to CDRS component
"debit_interval": "10s", // interval to perform debits on.
"min_call_duration": "0s", // only authorize calls with allowed duration higher than this

View File

@@ -470,6 +470,7 @@ func TestSmKamJsonCfg(t *testing.T) {
&HaPoolJsonCfg{
Address: utils.StringPointer(utils.MetaInternal),
}},
Cdrstats_conns: &[]*HaPoolJsonCfg{},
Create_cdr: utils.BoolPointer(false),
Debit_interval: utils.StringPointer("10s"),
Min_call_duration: utils.StringPointer("0s"),

View File

@@ -434,15 +434,15 @@ func TestCgrCfgJSONDefaultsSMKamConfig(t *testing.T) {
Enabled: false,
RALsConns: []*HaPoolConfig{&HaPoolConfig{Address: "*internal"}},
CDRsConns: []*HaPoolConfig{&HaPoolConfig{Address: "*internal"}},
CDRStatsConns: []*HaPoolConfig{},
CreateCdr: false,
DebitInterval: 10 * time.Second,
MinCallDuration: 0 * time.Second,
MaxCallDuration: 3 * time.Hour,
EvapiConns: []*KamConnConfig{&KamConnConfig{Address: "127.0.0.1:8448", Reconnects: 5}},
}
if !reflect.DeepEqual(cgrCfg.SmKamConfig, eSmKaCfg) {
t.Errorf("received: %+v, expecting: %+v", cgrCfg.CdreProfiles, eSmKaCfg)
t.Errorf("received: %+v, expecting: %+v", cgrCfg.SmKamConfig, eSmKaCfg)
}
}

View File

@@ -275,6 +275,7 @@ type SmKamJsonCfg struct {
Enabled *bool
Rals_conns *[]*HaPoolJsonCfg
Cdrs_conns *[]*HaPoolJsonCfg
Cdrstats_conns *[]*HaPoolJsonCfg
Create_cdr *bool
Debit_interval *string
Min_call_duration *string

View File

@@ -317,6 +317,7 @@ type SmKamConfig struct {
Enabled bool
RALsConns []*HaPoolConfig
CDRsConns []*HaPoolConfig
CDRStatsConns []*HaPoolConfig
CreateCdr bool
DebitInterval time.Duration
MinCallDuration time.Duration
@@ -346,6 +347,13 @@ func (self *SmKamConfig) loadFromJsonCfg(jsnCfg *SmKamJsonCfg) error {
self.CDRsConns[idx].loadFromJsonCfg(jsnHaCfg)
}
}
if jsnCfg.Cdrstats_conns != nil {
self.CDRStatsConns = make([]*HaPoolConfig, len(*jsnCfg.Cdrstats_conns))
for idx, jsnHaCfg := range *jsnCfg.Cdrstats_conns {
self.CDRStatsConns[idx] = NewDfltHaPoolConfig()
self.CDRStatsConns[idx].loadFromJsonCfg(jsnHaCfg)
}
}
if jsnCfg.Create_cdr != nil {
self.CreateCdr = *jsnCfg.Create_cdr
}