Add CacheS conns to RALs

This commit is contained in:
TeoV
2020-01-27 11:21:19 +02:00
parent 33bd07af40
commit ab343c94ac
4 changed files with 15 additions and 0 deletions

View File

@@ -234,6 +234,7 @@ const CGRATES_CFG_JSON = `
"enabled": false, // enable Rating/Accounting service: <true|false>
"thresholds_conns": [], // connections to ThresholdS for account/balance updates, empty to disable thresholds functionality: <""|*internal|x.y.z.y:1234>
"stats_conns": [], // connections to StatS for account/balance updates, empty to disable stats functionality: <""|*internal|x.y.z.y:1234>
"caches_conns":["*internal"], // connections to CacheS for account/balance updates
"rp_subject_prefix_matching": false, // enables prefix matching for the rating profile subject
"remove_expired":true, // enables automatic removal of expired balances
"max_computed_usage": { // do not compute usage higher than this, prevents memory overload

View File

@@ -390,6 +390,7 @@ func TestDfRalsJsonCfg(t *testing.T) {
Enabled: utils.BoolPointer(false),
Thresholds_conns: &[]string{},
Stats_conns: &[]string{},
CacheS_conns: &[]string{utils.MetaInternal},
Rp_subject_prefix_matching: utils.BoolPointer(false),
Remove_expired: utils.BoolPointer(true),
Max_computed_usage: &map[string]string{

View File

@@ -114,6 +114,7 @@ type RalsJsonCfg struct {
Enabled *bool
Thresholds_conns *[]string
Stats_conns *[]string
CacheS_conns *[]string
Rp_subject_prefix_matching *bool
Remove_expired *bool
Max_computed_usage *map[string]string

View File

@@ -29,6 +29,7 @@ type RalsCfg struct {
Enabled bool // start standalone server (no balancer)
ThresholdSConns []string // address where to reach ThresholdS config
StatSConns []string
CacheSConns []string
RpSubjectPrefixMatching bool // enables prefix matching for the rating profile subject
RemoveExpired bool
MaxComputedUsage map[string]time.Duration
@@ -66,6 +67,17 @@ func (ralsCfg *RalsCfg) loadFromJsonCfg(jsnRALsCfg *RalsJsonCfg) (err error) {
}
}
}
if jsnRALsCfg.CacheS_conns != nil {
ralsCfg.CacheSConns = make([]string, len(*jsnRALsCfg.CacheS_conns))
for idx, conn := range *jsnRALsCfg.CacheS_conns {
// if we have the connection internal we change the name so we can have internal rpc for each subsystem
if conn == utils.MetaInternal {
ralsCfg.CacheSConns[idx] = utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches)
} else {
ralsCfg.CacheSConns[idx] = conn
}
}
}
if jsnRALsCfg.Rp_subject_prefix_matching != nil {
ralsCfg.RpSubjectPrefixMatching = *jsnRALsCfg.Rp_subject_prefix_matching
}