From c8878f8b8749a22d87acc06ca8e37efdd06576e5 Mon Sep 17 00:00:00 2001 From: DanB Date: Sun, 7 Aug 2016 17:39:28 +0200 Subject: [PATCH] Adding ResourceLimiter configuration within SMFreeSWITCH --- config/config_defaults.go | 7 ++++--- config/config_json_test.go | 1 + config/libconfig_json.go | 1 + config/smconfig.go | 8 ++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/config/config_defaults.go b/config/config_defaults.go index 0cddbd957..2ff17f04a 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -250,13 +250,14 @@ const CGRATES_CFG_JSON = ` "sm_freeswitch": { - "enabled": false, // starts SessionManager service: + "enabled": false, // starts SessionManager service: "rals_conns": [ - {"address": "*internal"} // address where to reach the Rater <""|*internal|127.0.0.1:2013> + {"address": "*internal"} // address where to reach the Rater <""|*internal|127.0.0.1:2013> ], "cdrs_conns": [ - {"address": "*internal"} // address where to reach CDR Server, empty to disable CDR capturing <*internal|x.y.z.y:1234> + {"address": "*internal"} // address where to reach CDR Server, empty to disable CDR capturing <*internal|x.y.z.y:1234> ], + "rls_conns": [], // address where to reach the ResourceLimiter 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 "extra_fields": [], // extra fields to store in auth/CDRs when creating them "debit_interval": "10s", // interval to perform debits on. diff --git a/config/config_json_test.go b/config/config_json_test.go index 380850013..3c48253c2 100644 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -412,6 +412,7 @@ func TestSmFsJsonCfg(t *testing.T) { &HaPoolJsonCfg{ Address: utils.StringPointer(utils.MetaInternal), }}, + Rls_conns: &[]*HaPoolJsonCfg{}, Create_cdr: utils.BoolPointer(false), Extra_fields: utils.StringSlicePointer([]string{}), Debit_interval: utils.StringPointer("10s"), diff --git a/config/libconfig_json.go b/config/libconfig_json.go index 71da60a47..b3a1aadc6 100644 --- a/config/libconfig_json.go +++ b/config/libconfig_json.go @@ -192,6 +192,7 @@ type SmFsJsonCfg struct { Enabled *bool Rals_conns *[]*HaPoolJsonCfg Cdrs_conns *[]*HaPoolJsonCfg + Rls_conns *[]*HaPoolJsonCfg Create_cdr *bool Extra_fields *[]string Debit_interval *string diff --git a/config/smconfig.go b/config/smconfig.go index 9205baba4..0954967f5 100644 --- a/config/smconfig.go +++ b/config/smconfig.go @@ -163,6 +163,7 @@ type SmFsConfig struct { Enabled bool RALsConns []*HaPoolConfig CDRsConns []*HaPoolConfig + RLsConns []*HaPoolConfig CreateCdr bool ExtraFields []*utils.RSRField DebitInterval time.Duration @@ -200,6 +201,13 @@ func (self *SmFsConfig) loadFromJsonCfg(jsnCfg *SmFsJsonCfg) error { self.CDRsConns[idx].loadFromJsonCfg(jsnHaCfg) } } + if jsnCfg.Rls_conns != nil { + self.RLsConns = make([]*HaPoolConfig, len(*jsnCfg.Rls_conns)) + for idx, jsnHaCfg := range *jsnCfg.Rls_conns { + self.RLsConns[idx] = NewDfltHaPoolConfig() + self.RLsConns[idx].loadFromJsonCfg(jsnHaCfg) + } + } if jsnCfg.Create_cdr != nil { self.CreateCdr = *jsnCfg.Create_cdr }