mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 18:46:24 +05:00
RALs max_computed_usage config option
This commit is contained in:
@@ -65,6 +65,7 @@ func SetCgrConfig(cfg *CGRConfig) {
|
||||
|
||||
func NewDefaultCGRConfig() (*CGRConfig, error) {
|
||||
cfg := new(CGRConfig)
|
||||
cfg.RALsMaxComputedUsage = make(map[string]time.Duration)
|
||||
cfg.InstanceID = utils.GenUUID()
|
||||
cfg.DataFolderPath = "/usr/share/cgrates/"
|
||||
cfg.SmGenericConfig = new(SmGenericConfig)
|
||||
@@ -238,6 +239,7 @@ type CGRConfig struct {
|
||||
RALsAliasSConns []*HaPoolConfig
|
||||
RpSubjectPrefixMatching bool // enables prefix matching for the rating profile subject
|
||||
LcrSubjectPrefixMatching bool // enables prefix matching for the lcr subject
|
||||
RALsMaxComputedUsage map[string]time.Duration
|
||||
SchedulerEnabled bool
|
||||
CDRSEnabled bool // Enable CDR Server service
|
||||
CDRSExtraFields []*utils.RSRField // Extra fields to store in CDRs
|
||||
@@ -917,6 +919,13 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) (err error) {
|
||||
if jsnRALsCfg.Lcr_subject_prefix_matching != nil {
|
||||
self.LcrSubjectPrefixMatching = *jsnRALsCfg.Lcr_subject_prefix_matching
|
||||
}
|
||||
if jsnRALsCfg.Max_computed_usage != nil {
|
||||
for k, v := range *jsnRALsCfg.Max_computed_usage {
|
||||
if self.RALsMaxComputedUsage[k], err = utils.ParseDurationWithNanosecs(v); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if jsnSchedCfg != nil && jsnSchedCfg.Enabled != nil {
|
||||
self.SchedulerEnabled = *jsnSchedCfg.Enabled
|
||||
|
||||
@@ -138,7 +138,13 @@ const CGRATES_CFG_JSON = `
|
||||
"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>
|
||||
"rp_subject_prefix_matching": false, // enables prefix matching for the rating profile subject
|
||||
"lcr_subject_prefix_matching": false // enables prefix matching for the lcr subject
|
||||
"lcr_subject_prefix_matching": false, // enables prefix matching for the lcr subject
|
||||
"max_computed_usage": { // do not compute usage higher than this, prevents memory overload
|
||||
"*any": "189h",
|
||||
"*voice": "72h",
|
||||
"*data": "107374182400",
|
||||
"*sms": "10000"
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -195,11 +195,23 @@ func TestDfStorDBJsonCfg(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDfRalsJsonCfg(t *testing.T) {
|
||||
eCfg := &RalsJsonCfg{Enabled: utils.BoolPointer(false), Thresholds_conns: &[]*HaPoolJsonCfg{},
|
||||
Cdrstats_conns: &[]*HaPoolJsonCfg{}, Stats_conns: &[]*HaPoolJsonCfg{},
|
||||
Historys_conns: &[]*HaPoolJsonCfg{}, Pubsubs_conns: &[]*HaPoolJsonCfg{},
|
||||
Users_conns: &[]*HaPoolJsonCfg{}, Aliases_conns: &[]*HaPoolJsonCfg{},
|
||||
Rp_subject_prefix_matching: utils.BoolPointer(false), Lcr_subject_prefix_matching: utils.BoolPointer(false)}
|
||||
eCfg := &RalsJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Thresholds_conns: &[]*HaPoolJsonCfg{},
|
||||
Cdrstats_conns: &[]*HaPoolJsonCfg{},
|
||||
Stats_conns: &[]*HaPoolJsonCfg{},
|
||||
Historys_conns: &[]*HaPoolJsonCfg{},
|
||||
Pubsubs_conns: &[]*HaPoolJsonCfg{},
|
||||
Users_conns: &[]*HaPoolJsonCfg{},
|
||||
Aliases_conns: &[]*HaPoolJsonCfg{},
|
||||
Rp_subject_prefix_matching: utils.BoolPointer(false),
|
||||
Lcr_subject_prefix_matching: utils.BoolPointer(false),
|
||||
Max_computed_usage: &map[string]string{
|
||||
utils.ANY: "189h",
|
||||
utils.VOICE: "72h",
|
||||
utils.DATA: "107374182400",
|
||||
utils.SMS: "10000"},
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.RalsJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(eCfg, cfg) {
|
||||
|
||||
@@ -318,6 +318,15 @@ func TestCgrCfgJSONDefaultsRALs(t *testing.T) {
|
||||
if cgrCfg.LcrSubjectPrefixMatching != false {
|
||||
t.Error(cgrCfg.LcrSubjectPrefixMatching)
|
||||
}
|
||||
eMaxCU := map[string]time.Duration{
|
||||
utils.ANY: time.Duration(189 * time.Hour),
|
||||
utils.VOICE: time.Duration(72 * time.Hour),
|
||||
utils.DATA: time.Duration(107374182400),
|
||||
utils.SMS: time.Duration(10000),
|
||||
}
|
||||
if !reflect.DeepEqual(eMaxCU, cgrCfg.RALsMaxComputedUsage) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eMaxCU, cgrCfg.RALsMaxComputedUsage)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCgrCfgJSONDefaultsScheduler(t *testing.T) {
|
||||
|
||||
@@ -89,6 +89,7 @@ type RalsJsonCfg struct {
|
||||
Users_conns *[]*HaPoolJsonCfg
|
||||
Rp_subject_prefix_matching *bool
|
||||
Lcr_subject_prefix_matching *bool
|
||||
Max_computed_usage *map[string]string
|
||||
}
|
||||
|
||||
// Scheduler config section
|
||||
|
||||
Reference in New Issue
Block a user