mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Adding CDRs sm_cost_retries configuration option
This commit is contained in:
@@ -233,6 +233,7 @@ type CGRConfig struct {
|
||||
CDRSExtraFields []*utils.RSRField // Extra fields to store in CDRs
|
||||
CDRSStoreCdrs bool // store cdrs in storDb
|
||||
CDRScdrAccountSummary bool
|
||||
CDRSSMCostRetries int
|
||||
CDRSRaterConns []*HaPoolConfig // address where to reach the Rater for cost calculation: <""|internal|x.y.z.y:1234>
|
||||
CDRSPubSubSConns []*HaPoolConfig // address where to reach the pubsub service: <""|internal|x.y.z.y:1234>
|
||||
CDRSUserSConns []*HaPoolConfig // address where to reach the users service: <""|internal|x.y.z.y:1234>
|
||||
@@ -841,6 +842,9 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) error {
|
||||
if jsnCdrsCfg.Cdr_account_summary != nil {
|
||||
self.CDRScdrAccountSummary = *jsnCdrsCfg.Cdr_account_summary
|
||||
}
|
||||
if jsnCdrsCfg.Sm_cost_retries != nil {
|
||||
self.CDRSSMCostRetries = *jsnCdrsCfg.Sm_cost_retries
|
||||
}
|
||||
if jsnCdrsCfg.Rals_conns != nil {
|
||||
self.CDRSRaterConns = make([]*HaPoolConfig, len(*jsnCdrsCfg.Rals_conns))
|
||||
for idx, jsnHaCfg := range *jsnCdrsCfg.Rals_conns {
|
||||
|
||||
@@ -134,6 +134,7 @@ const CGRATES_CFG_JSON = `
|
||||
"extra_fields": [], // extra fields to store in CDRs for non-generic CDRs
|
||||
"store_cdrs": true, // store cdrs in storDb
|
||||
"cdr_account_summary": false, // add account information from dataDB
|
||||
"sm_cost_retries": 5, // number of queries to sm_costs before recalculating CDR
|
||||
"rals_conns": [
|
||||
{"address": "*internal"} // address where to reach the Rater for cost calculation, empty to disable functionality: <""|*internal|x.y.z.y:1234>
|
||||
],
|
||||
|
||||
@@ -177,6 +177,7 @@ func TestDfCdrsJsonCfg(t *testing.T) {
|
||||
Extra_fields: utils.StringSlicePointer([]string{}),
|
||||
Store_cdrs: utils.BoolPointer(true),
|
||||
Cdr_account_summary: utils.BoolPointer(false),
|
||||
Sm_cost_retries: utils.IntPointer(5),
|
||||
Rals_conns: &[]*HaPoolJsonCfg{
|
||||
&HaPoolJsonCfg{
|
||||
Address: utils.StringPointer("*internal"),
|
||||
|
||||
@@ -88,6 +88,7 @@ type CdrsJsonCfg struct {
|
||||
Extra_fields *[]string
|
||||
Store_cdrs *bool
|
||||
Cdr_account_summary *bool
|
||||
Sm_cost_retries *int
|
||||
Rals_conns *[]*HaPoolJsonCfg
|
||||
Pubsubs_conns *[]*HaPoolJsonCfg
|
||||
Users_conns *[]*HaPoolJsonCfg
|
||||
|
||||
@@ -365,7 +365,7 @@ func (self *CdrServer) rateCDR(cdr *CDR) ([]*CDR, error) {
|
||||
// Should be previously calculated and stored in DB
|
||||
delay := utils.Fib()
|
||||
var smCosts []*SMCost
|
||||
for i := 0; i < 4; i++ {
|
||||
for i := 0; i < self.cgrCfg.CDRSSMCostRetries; i++ {
|
||||
smCosts, err = self.cdrDb.GetSMCosts(cdr.CGRID, cdr.RunID, cdr.OriginHost, cdr.ExtraFields[utils.OriginIDPrefix])
|
||||
if err == nil && len(smCosts) != 0 {
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user