diff --git a/accounts/abstractbalance.go b/accounts/abstractbalance.go index 517e991e4..d2e8333d6 100644 --- a/accounts/abstractbalance.go +++ b/accounts/abstractbalance.go @@ -93,7 +93,7 @@ func (aB *abstractBalance) debitAbstracts(ctx *context.Context, usage *decimal.B hasUF = true } if blncLmt != nil { - maxBlcDbt := new(decimal.Big).Copy(aB.blnCfg.Units.Big) + maxBlcDbt := utils.CloneDecimalBig(aB.blnCfg.Units.Big) if hasUF { maxBlcDbt = utils.DivideBig(maxBlcDbt, uF.Factor.Big) // common units with debit and increments } @@ -124,7 +124,7 @@ func (aB *abstractBalance) debitAbstracts(ctx *context.Context, usage *decimal.B usage = ecCost.Abstracts.Big dbtUnits = ecCost.Abstracts.Big } else { - dbtUnits = new(decimal.Big).Copy(usage) + dbtUnits = utils.CloneDecimalBig(usage) } if hasUF { dbtUnits = utils.MultiplyBig(dbtUnits, uF.Factor.Big) diff --git a/accounts/accounts.go b/accounts/accounts.go index 0b944a960..bd55e9a69 100644 --- a/accounts/accounts.go +++ b/accounts/accounts.go @@ -148,7 +148,7 @@ func (aS *AccountS) accountsDebit(ctx *context.Context, acnts []*utils.AccountWi acntBkps[i] = acnt.Account.AccountBalancesBackup() var ecDbt *utils.EventCharges if ecDbt, err = aS.accountDebit(ctx, acnt.Account, - new(decimal.Big).Copy(usage), cgrEv, concretes, dbted); err != nil { + utils.CloneDecimalBig(usage), cgrEv, concretes, dbted); err != nil { if store { restoreAccounts(ctx, aS.dm, acnts, acntBkps) } @@ -207,7 +207,7 @@ func (aS *AccountS) accountDebit(ctx *context.Context, acnt *utils.Account, usag return // no more debit } var ecDbt *utils.EventCharges - if ecDbt, err = debFunc(ctx, new(decimal.Big).Copy(usage), cgrEv, dbted); err != nil { + if ecDbt, err = debFunc(ctx, utils.CloneDecimalBig(usage), cgrEv, dbted); err != nil { if err == utils.ErrFilterNotPassingNoCaps || err == utils.ErrNotImplemented { err = nil diff --git a/accounts/accounts_test.go b/accounts/accounts_test.go index def63ea5b..a777242bf 100644 --- a/accounts/accounts_test.go +++ b/accounts/accounts_test.go @@ -1891,7 +1891,7 @@ func TestV1DebitAbstractsEventCharges(t *testing.T) { /* acnt1.Balances[ab1ID].Units = utils.NewDecimal(int64(10*time.Second), 0) acnt1.Balances[cb1ID].Units = utils.NewDecimal(-200, 0) - acnt1.Balances[ab2ID].Units = &utils.Decimal{new(decimal.Big).CopySign(decimal.New(0, 0), decimal.New(-1, 0))} // negative 0 + acnt1.Balances[ab2ID].Units = &utils.Decimal{decimal.WithContext(DecimalContext).CopySign(decimal.New(0, 0), decimal.New(-1, 0))} // negative 0 acnt1.Balances[cb2ID].Units = utils.NewDecimal(0, 0) if rcv, err := dm.GetAccount(acnt1.Tenant, acnt1.ID); err != nil { t.Error(err) @@ -2411,7 +2411,7 @@ func TestDebitAbstractUsingRatesWithRoundByIncrement(t *testing.T) { }, }, Type: utils.MetaAbstract, - Units: &utils.Decimal{utils.SumDecimalAsBig(&utils.Decimal{utils.NewDecimal(0, 0).Neg(utils.NewDecimal(1, 0).Big)}, utils.NewDecimal(1, 0))}, // this should be -0 + Units: utils.SumDecimal(&utils.Decimal{utils.NewDecimal(0, 0).Neg(utils.NewDecimal(1, 0).Big)}, utils.NewDecimal(1, 0)), // this should be -0 CostIncrements: []*utils.CostIncrement{ { Increment: utils.NewDecimal(int64(time.Second), 0), diff --git a/accounts/libaccounts.go b/accounts/libaccounts.go index 207d60f9a..18770f2d4 100644 --- a/accounts/libaccounts.go +++ b/accounts/libaccounts.go @@ -185,7 +185,7 @@ func debitConcreteUnits(ctx *context.Context, cUnits *decimal.Big, clnedUnts := cloneUnitsFromConcretes(cncrtBlncs) for _, cB := range cncrtBlncs { var ecCncrt *utils.EventCharges - if ecCncrt, err = cB.debitConcretes(ctx, new(decimal.Big).Copy(cUnits), cgrEv, nil); err != nil { + if ecCncrt, err = cB.debitConcretes(ctx, utils.CloneDecimalBig(cUnits), cgrEv, nil); err != nil { restoreUnitsFromClones(cncrtBlncs, clnedUnts) return nil, err } @@ -280,7 +280,7 @@ func maxDebitAbstractsFromConcretes(ctx *context.Context, aUnits *decimal.Big, } err = nil // ErrInsufficientCredit - aDenied = new(decimal.Big).Copy(aUnits) + aDenied = utils.CloneDecimalBig(aUnits) if aPaid == nil { // going backwards aUnits = utils.DivideBig( // divide by 2 aUnits, decimal.New(2, 0)) @@ -293,7 +293,7 @@ func maxDebitAbstractsFromConcretes(ctx *context.Context, aUnits *decimal.Big, continue } } else { // debit for the usage succeeded - aPaid = new(decimal.Big).Copy(aUnits) + aPaid = utils.CloneDecimalBig(aUnits) paidConcrtUnts = cloneUnitsFromConcretes(cncrtBlncs) if ec == nil { ec = utils.NewEventCharges() diff --git a/config/accountscfg_test.go b/config/accountscfg_test.go index bf0c58921..4679bdd6b 100644 --- a/config/accountscfg_test.go +++ b/config/accountscfg_test.go @@ -89,7 +89,7 @@ func TestAccountSCfgLoadFromJSONCfgOptsErr(t *testing.T) { }, Usage: []*utils.DynamicDecimalBigOpt{ { - Value: new(decimal.Big).SetUint64(2), + Value: decimal.WithContext(utils.DecimalContext).SetUint64(2), }, }, ProfileIgnoreFilters: []*utils.DynamicBoolOpt{ @@ -251,7 +251,7 @@ func TestDiffAccountSJsonCfg(t *testing.T) { Usage: []*utils.DynamicDecimalBigOpt{ { Tenant: "cgrates.org", - Value: new(decimal.Big).SetUint64(1), + Value: decimal.WithContext(utils.DecimalContext).SetUint64(1), }, }, ProfileIgnoreFilters: []*utils.DynamicBoolOpt{ @@ -285,7 +285,7 @@ func TestDiffAccountSJsonCfg(t *testing.T) { Usage: []*utils.DynamicDecimalBigOpt{ { Tenant: "cgrates.net", - Value: new(decimal.Big).SetUint64(2), + Value: decimal.WithContext(utils.DecimalContext).SetUint64(2), }, }, ProfileIgnoreFilters: []*utils.DynamicBoolOpt{ diff --git a/config/config_defaults.go b/config/config_defaults.go index 928053a32..6aa251a70 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -53,6 +53,10 @@ const CGRATES_CFG_JSON = ` "digest_equal": ":", // equal symbol used in case of digests "rsr_separator": ";", // separator used within RSR fields "max_parallel_conns": 100, // the maximum number of connection used by the *parallel strategy + "decimal_max_scale": 0, // the maximum scale for decimal numbers + "decimal_min_scale": 0, // the minimum scale for decimal numbers + "decimal_precision": 0, // the precision of the decimal operations + "decimal_rounding_mode": "ToNearestEven", // the rounding mode }, diff --git a/config/config_json.go b/config/config_json.go index 0efa312fb..d70c5dfb8 100644 --- a/config/config_json.go +++ b/config/config_json.go @@ -73,6 +73,7 @@ const ( var ( SectionToService = map[string]string{ + GeneralJSON: utils.GlobalVarS, AttributeSJSON: utils.AttributeS, ChargerSJSON: utils.ChargerS, ThresholdSJSON: utils.ThresholdS, diff --git a/config/config_json_test.go b/config/config_json_test.go index fdc7d8241..31bd69098 100644 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -31,29 +31,33 @@ import ( func TestDfGeneralJsonCfg(t *testing.T) { eCfg := &GeneralJsonCfg{ - Node_id: utils.StringPointer(""), - Logger: utils.StringPointer(utils.MetaSysLog), - Log_level: utils.IntPointer(utils.LOGLEVEL_INFO), - Rounding_decimals: utils.IntPointer(5), - Dbdata_encoding: utils.StringPointer("*msgpack"), - Tpexport_dir: utils.StringPointer("/var/spool/cgrates/tpe"), - Poster_attempts: utils.IntPointer(3), - Failed_posts_dir: utils.StringPointer("/var/spool/cgrates/failed_posts"), - Failed_posts_ttl: utils.StringPointer("5s"), - Default_request_type: utils.StringPointer(utils.MetaRated), - Default_category: utils.StringPointer("call"), - Default_tenant: utils.StringPointer("cgrates.org"), - Default_caching: utils.StringPointer(utils.MetaReload), - Default_timezone: utils.StringPointer("Local"), - Connect_attempts: utils.IntPointer(5), - Reconnects: utils.IntPointer(-1), - Connect_timeout: utils.StringPointer("1s"), - Reply_timeout: utils.StringPointer("2s"), - Locking_timeout: utils.StringPointer("0"), - Digest_separator: utils.StringPointer(","), - Digest_equal: utils.StringPointer(":"), - Rsr_separator: utils.StringPointer(";"), - Max_parallel_conns: utils.IntPointer(100), + Node_id: utils.StringPointer(""), + Logger: utils.StringPointer(utils.MetaSysLog), + Log_level: utils.IntPointer(utils.LOGLEVEL_INFO), + Rounding_decimals: utils.IntPointer(5), + Dbdata_encoding: utils.StringPointer("*msgpack"), + Tpexport_dir: utils.StringPointer("/var/spool/cgrates/tpe"), + Poster_attempts: utils.IntPointer(3), + Failed_posts_dir: utils.StringPointer("/var/spool/cgrates/failed_posts"), + Failed_posts_ttl: utils.StringPointer("5s"), + Default_request_type: utils.StringPointer(utils.MetaRated), + Default_category: utils.StringPointer("call"), + Default_tenant: utils.StringPointer("cgrates.org"), + Default_caching: utils.StringPointer(utils.MetaReload), + Default_timezone: utils.StringPointer("Local"), + Connect_attempts: utils.IntPointer(5), + Reconnects: utils.IntPointer(-1), + Connect_timeout: utils.StringPointer("1s"), + Reply_timeout: utils.StringPointer("2s"), + Locking_timeout: utils.StringPointer("0"), + Digest_separator: utils.StringPointer(","), + Digest_equal: utils.StringPointer(":"), + Rsr_separator: utils.StringPointer(";"), + Max_parallel_conns: utils.IntPointer(100), + Decimal_max_scale: utils.IntPointer(0), + Decimal_min_scale: utils.IntPointer(0), + Decimal_precision: utils.IntPointer(0), + Decimal_rounding_mode: utils.StringPointer("ToNearestEven"), } dfCgrJSONCfg, err := NewCgrJsonCfgFromBytes([]byte(CGRATES_CFG_JSON)) if err != nil { diff --git a/config/config_test.go b/config/config_test.go index f024368e4..e7b0986eb 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -3819,29 +3819,33 @@ func TestV1GetConfigGeneral(t *testing.T) { } }` expected := map[string]interface{}{ - utils.NodeIDCfg: "ENGINE1", - utils.LoggerCfg: "*syslog", - utils.LogLevelCfg: 6, - utils.RoundingDecimalsCfg: 5, - utils.DBDataEncodingCfg: "*msgpack", - utils.TpExportPathCfg: "/var/spool/cgrates/tpe", - utils.PosterAttemptsCfg: 3, - utils.FailedPostsDirCfg: "/var/spool/cgrates/failed_posts", - utils.FailedPostsTTLCfg: "0", - utils.DefaultReqTypeCfg: "*rated", - utils.DefaultCategoryCfg: "call", - utils.DefaultTenantCfg: "cgrates.org", - utils.DefaultTimezoneCfg: "Local", - utils.DefaultCachingCfg: "*reload", - utils.ConnectAttemptsCfg: 5, - utils.ReconnectsCfg: -1, - utils.ConnectTimeoutCfg: "0", - utils.ReplyTimeoutCfg: "0", - utils.LockingTimeoutCfg: "0", - utils.DigestSeparatorCfg: ",", - utils.DigestEqualCfg: ":", - utils.RSRSepCfg: ";", - utils.MaxParallelConnsCfg: 100, + utils.NodeIDCfg: "ENGINE1", + utils.LoggerCfg: "*syslog", + utils.LogLevelCfg: 6, + utils.RoundingDecimalsCfg: 5, + utils.DBDataEncodingCfg: "*msgpack", + utils.TpExportPathCfg: "/var/spool/cgrates/tpe", + utils.PosterAttemptsCfg: 3, + utils.FailedPostsDirCfg: "/var/spool/cgrates/failed_posts", + utils.FailedPostsTTLCfg: "0", + utils.DefaultReqTypeCfg: "*rated", + utils.DefaultCategoryCfg: "call", + utils.DefaultTenantCfg: "cgrates.org", + utils.DefaultTimezoneCfg: "Local", + utils.DefaultCachingCfg: "*reload", + utils.ConnectAttemptsCfg: 5, + utils.ReconnectsCfg: -1, + utils.ConnectTimeoutCfg: "0", + utils.ReplyTimeoutCfg: "0", + utils.LockingTimeoutCfg: "0", + utils.DigestSeparatorCfg: ",", + utils.DigestEqualCfg: ":", + utils.RSRSepCfg: ";", + utils.MaxParallelConnsCfg: 100, + utils.DecimalMaxScaleCfg: 0, + utils.DecimalMinScaleCfg: 0, + utils.DecimalPrecisionCfg: 0, + utils.DecimalRoundingModeCfg: "ToNearestEven", } expected = map[string]interface{}{ GeneralJSON: expected, @@ -5052,7 +5056,7 @@ func TestV1GetConfigAsJSONGeneral(t *testing.T) { "node_id": "ENGINE1", } }` - expected := `{"general":{"connect_attempts":5,"connect_timeout":"1s","dbdata_encoding":"*msgpack","default_caching":"*reload","default_category":"call","default_request_type":"*rated","default_tenant":"cgrates.org","default_timezone":"Local","digest_equal":":","digest_separator":",","failed_posts_dir":"/var/spool/cgrates/failed_posts","failed_posts_ttl":"5s","locking_timeout":"0","log_level":6,"logger":"*syslog","max_parallel_conns":100,"node_id":"ENGINE1","poster_attempts":3,"reconnects":-1,"reply_timeout":"2s","rounding_decimals":5,"rsr_separator":";","tpexport_dir":"/var/spool/cgrates/tpe"}}` + expected := `{"general":{"connect_attempts":5,"connect_timeout":"1s","dbdata_encoding":"*msgpack","decimal_max_scale":0,"decimal_min_scale":0,"decimal_precision":0,"decimal_rounding_mode":"ToNearestEven","default_caching":"*reload","default_category":"call","default_request_type":"*rated","default_tenant":"cgrates.org","default_timezone":"Local","digest_equal":":","digest_separator":",","failed_posts_dir":"/var/spool/cgrates/failed_posts","failed_posts_ttl":"5s","locking_timeout":"0","log_level":6,"logger":"*syslog","max_parallel_conns":100,"node_id":"ENGINE1","poster_attempts":3,"reconnects":-1,"reply_timeout":"2s","rounding_decimals":5,"rsr_separator":";","tpexport_dir":"/var/spool/cgrates/tpe"}}` if cfgCgr, err := NewCGRConfigFromJSONStringWithDefaults(strJSON); err != nil { t.Error(err) } else if err := cfgCgr.V1GetConfigAsJSON(context.Background(), &SectionWithAPIOpts{Sections: []string{GeneralJSON}}, &reply); err != nil { @@ -5558,7 +5562,7 @@ func TestV1GetConfigAsJSONAllConfig(t *testing.T) { } }` var reply string - expected := `{"accounts":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"max_iterations":1000,"max_usage":"259200000000000","nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[],"*usage":[]},"prefix_indexed_fields":[],"rates_conns":[],"suffix_indexed_fields":[],"thresholds_conns":[]},"actions":{"accounts_conns":[],"cdrs_conns":[],"dynaprepaid_actionprofile":[],"ees_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[]},"prefix_indexed_fields":[],"stats_conns":[],"suffix_indexed_fields":[],"tenants":[],"thresholds_conns":[]},"admins":{"actions_conns":[],"attributes_conns":[],"caches_conns":["*internal"],"ees_conns":[],"enabled":false},"analyzers":{"cleanup_interval":"1h0m0s","db_path":"/var/spool/cgrates/analyzers","enabled":false,"index_type":"*scorch","ttl":"24h0m0s"},"apiban":{"enabled":false,"keys":[]},"asterisk_agent":{"asterisk_conns":[{"address":"127.0.0.1:8088","alias":"","connect_attempts":3,"password":"CGRateS.org","reconnects":5,"user":"cgrates"}],"create_cdr":false,"enabled":false,"sessions_conns":["*birpc_internal"]},"attributes":{"accounts_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*processRuns":[],"*profileIDs":[],"*profileIgnoreFilters":[],"*profileRuns":[]},"prefix_indexed_fields":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_loads":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*event_charges":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"replication_conns":[]},"cdrs":{"accounts_conns":[],"actions_conns":[],"attributes_conns":[],"chargers_conns":[],"ees_conns":[],"enabled":false,"extra_fields":[],"online_cdr_exports":null,"opts":{"*accountS":[],"*attributeS":[],"*chargerS":[],"*eeS":[],"*rateS":[],"*statS":[],"*thresholdS":[]},"rates_conns":[],"session_cost_retries":5,"stats_conns":[],"store_cdrs":true,"thresholds_conns":[]},"chargers":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"config_db":{"db_host":"","db_name":"","db_password":"","db_port":0,"db_type":"*internal","db_user":"","opts":{"mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisSentinel":"","redisTLS":false}},"configs":{"enabled":false,"root_dir":"/var/spool/cgrates/configs","url":"/configs/"},"cores":{"caps":0,"caps_stats_interval":"0","caps_strategy":"*busy","ees_conns":[],"shutdown_timeout":"1s"},"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*account_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*actions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*stat_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false},"diameter_agent":{"asr_template":"","concurrent_requests":-1,"dictionaries_path":"/usr/share/cgrates/diameter/dict/","enabled":false,"forced_disconnect":"*none","listen":"127.0.0.1:3868","listen_net":"tcp","origin_host":"CGR-DA","origin_realm":"cgrates.org","product_name":"CGRateS","rar_template":"","request_processors":[],"sessions_conns":["*birpc_internal"],"synced_conn_requests":false,"vendor_id":0},"dispatchers":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"dns_agent":{"enabled":false,"listen":"127.0.0.1:2053","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"],"timezone":""},"ees":{"attributes_conns":[],"cache":{"*fileCSV":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"enabled":false,"exporters":[{"attempts":1,"attribute_context":"","attribute_ids":[],"concurrent_requests":0,"export_path":"/var/spool/cgrates/ees","failed_posts_dir":"/var/spool/cgrates/failed_posts","fields":[],"filters":[],"flags":[],"id":"*default","opts":{},"synchronous":false,"timezone":"","type":"*none"}]},"ers":{"enabled":false,"partial_cache_ttl":"1s","readers":[{"cache_dump_fields":[],"concurrent_requests":1024,"fields":[{"mandatory":true,"path":"*cgreq.ToR","tag":"ToR","type":"*variable","value":"~*req.2"},{"mandatory":true,"path":"*cgreq.OriginID","tag":"OriginID","type":"*variable","value":"~*req.3"},{"mandatory":true,"path":"*cgreq.RequestType","tag":"RequestType","type":"*variable","value":"~*req.4"},{"mandatory":true,"path":"*cgreq.Tenant","tag":"Tenant","type":"*variable","value":"~*req.6"},{"mandatory":true,"path":"*cgreq.Category","tag":"Category","type":"*variable","value":"~*req.7"},{"mandatory":true,"path":"*cgreq.Account","tag":"Account","type":"*variable","value":"~*req.8"},{"mandatory":true,"path":"*cgreq.Subject","tag":"Subject","type":"*variable","value":"~*req.9"},{"mandatory":true,"path":"*cgreq.Destination","tag":"Destination","type":"*variable","value":"~*req.10"},{"mandatory":true,"path":"*cgreq.SetupTime","tag":"SetupTime","type":"*variable","value":"~*req.11"},{"mandatory":true,"path":"*cgreq.AnswerTime","tag":"AnswerTime","type":"*variable","value":"~*req.12"},{"mandatory":true,"path":"*cgreq.Usage","tag":"Usage","type":"*variable","value":"~*req.13"}],"filters":[],"flags":[],"id":"*default","opts":{"csvFieldSeparator":",","csvHeaderDefineChar":":","csvRowLength":0,"natsSubject":"cgrates_cdrs","partialCacheAction":"*none","partialOrderField":"~*req.AnswerTime","xmlRootPath":""},"partial_commit_fields":[],"processed_path":"/var/spool/cgrates/ers/out","run_delay":"0","source_path":"/var/spool/cgrates/ers/in","tenant":"","timezone":"","type":"*none"}],"sessions_conns":["*internal"]},"filters":{"accounts_conns":[],"resources_conns":[],"stats_conns":[]},"freeswitch_agent":{"create_cdr":false,"empty_balance_ann_file":"","empty_balance_context":"","enabled":false,"event_socket_conns":[{"address":"127.0.0.1:8021","alias":"127.0.0.1:8021","password":"ClueCon","reconnects":5}],"extra_fields":[],"low_balance_ann_file":"","max_wait_connection":"2s","sessions_conns":["*birpc_internal"],"subscribe_park":true},"general":{"connect_attempts":5,"connect_timeout":"1s","dbdata_encoding":"*msgpack","default_caching":"*reload","default_category":"call","default_request_type":"*rated","default_tenant":"cgrates.org","default_timezone":"Local","digest_equal":":","digest_separator":",","failed_posts_dir":"/var/spool/cgrates/failed_posts","failed_posts_ttl":"5s","locking_timeout":"0","log_level":6,"logger":"*syslog","max_parallel_conns":100,"node_id":"ENGINE1","poster_attempts":3,"reconnects":-1,"reply_timeout":"2s","rounding_decimals":5,"rsr_separator":";","tpexport_dir":"/var/spool/cgrates/tpe"},"http":{"auth_users":{},"client_opts":{"dialFallbackDelay":"300ms","dialKeepAlive":"30s","dialTimeout":"30s","disableCompression":false,"disableKeepAlives":false,"expectContinueTimeout":"0s","forceAttemptHttp2":true,"idleConnTimeout":"1m30s","maxConnsPerHost":0,"maxIdleConns":100,"maxIdleConnsPerHost":2,"responseHeaderTimeout":"0s","skipTLSVerification":false,"tlsHandshakeTimeout":"10s"},"freeswitch_cdrs_url":"/freeswitch_json","http_cdrs":"/cdr_http","json_rpc_url":"/jsonrpc","registrars_url":"/registrar","use_basic_auth":false,"ws_url":"/ws"},"http_agent":[],"kamailio_agent":{"create_cdr":false,"enabled":false,"evapi_conns":[{"address":"127.0.0.1:8448","alias":"","reconnects":5}],"sessions_conns":["*birpc_internal"],"timezone":""},"listen":{"http":"127.0.0.1:2080","http_tls":"127.0.0.1:2280","rpc_gob":"127.0.0.1:2013","rpc_gob_tls":"127.0.0.1:2023","rpc_json":"127.0.0.1:2012","rpc_json_tls":"127.0.0.1:2022"},"loader":{"actions_conns":["*localhost"],"caches_conns":["*localhost"],"data_path":"./","disable_reverse":false,"field_separator":",","gapi_credentials":".gapi/credentials.json","gapi_token":".gapi/token.json","tpid":""},"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"AttributeFilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.4"},{"path":"Path","tag":"Path","type":"*variable","value":"~*req.5"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.6"},{"path":"Value","tag":"Value","type":"*variable","value":"~*req.7"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.8"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.6"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.7"},{"path":"MetricFilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.4"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.5"},{"path":"RouteID","tag":"RouteID","type":"*variable","value":"~*req.6"},{"path":"RouteFilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.7"},{"path":"RouteAccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.8"},{"path":"RouteRateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.9"},{"path":"RouteResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.10"},{"path":"RouteStatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.11"},{"path":"RouteWeights","tag":"RouteWeights","type":"*variable","value":"~*req.12"},{"path":"RouteBlocker","tag":"RouteBlocker","type":"*variable","value":"~*req.13"},{"path":"RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.14"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.4"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.5"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.4"},{"path":"StrategyParameters","tag":"StrategyParameters","type":"*variable","value":"~*req.5"},{"path":"ConnID","tag":"ConnID","type":"*variable","value":"~*req.6"},{"path":"ConnFilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.7"},{"path":"ConnWeight","tag":"ConnWeight","type":"*variable","value":"~*req.8"},{"path":"ConnBlocker","tag":"ConnBlocker","type":"*variable","value":"~*req.9"},{"path":"ConnParameters","tag":"ConnParameters","type":"*variable","value":"~*req.10"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"ConnectAttempts","tag":"ConnectAttempts","type":"*variable","value":"~*req.4"},{"path":"Reconnects","tag":"Reconnects","type":"*variable","value":"~*req.5"},{"path":"ConnectTimeout","tag":"ConnectTimeout","type":"*variable","value":"~*req.6"},{"path":"ReplyTimeout","tag":"ReplyTimeout","type":"*variable","value":"~*req.7"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.8"},{"path":"ClientKey","tag":"ClientKey","type":"*variable","value":"~*req.9"},{"path":"ClientCertificate","tag":"ClientCertificate","type":"*variable","value":"~*req.10"},{"path":"CaCertificate","tag":"CaCertificate","type":"*variable","value":"~*req.11"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"path":"RateID","tag":"RateID","type":"*variable","value":"~*req.7"},{"path":"RateFilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"path":"RateActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"path":"RateWeights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"path":"RateBlocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"path":"RateIntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"path":"RateFixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"path":"RateRecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"path":"RateUnit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"path":"RateIncrement","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.4"},{"path":"TargetType","tag":"TargetType","type":"*variable","value":"~*req.5"},{"path":"TargetIDs","tag":"TargetIDs","type":"*variable","value":"~*req.6"},{"path":"ActionID","tag":"ActionID","type":"*variable","value":"~*req.7"},{"path":"ActionFilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.8"},{"path":"ActionBlocker","tag":"ActionBlocker","type":"*variable","value":"~*req.9"},{"path":"ActionTTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"path":"ActionType","tag":"ActionType","type":"*variable","value":"~*req.11"},{"path":"ActionOpts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"path":"ActionPath","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"path":"ActionValue","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.4"},{"path":"BalanceID","tag":"BalanceID","type":"*variable","value":"~*req.5"},{"path":"BalanceFilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.6"},{"path":"BalanceWeights","tag":"BalanceWeights","type":"*variable","value":"~*req.7"},{"path":"BalanceType","tag":"BalanceType","type":"*variable","value":"~*req.8"},{"path":"BalanceUnits","tag":"BalanceUnits","type":"*variable","value":"~*req.9"},{"path":"BalanceUnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.10"},{"path":"BalanceOpts","tag":"BalanceOpts","type":"*variable","value":"~*req.11"},{"path":"BalanceCostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.12"},{"path":"BalanceAttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.13"},{"path":"BalanceRateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.14"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.15"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}],"migrator":{"out_datadb_encoding":"msgpack","out_datadb_host":"127.0.0.1","out_datadb_name":"10","out_datadb_opts":{"mongoQueryTimeout":"0s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"out_datadb_password":"","out_datadb_port":"6379","out_datadb_type":"redis","out_datadb_user":"cgrates","out_stordb_host":"127.0.0.1","out_stordb_name":"cgrates","out_stordb_opts":{"mongoQueryTimeout":"0s","mysqlLocation":"","sqlConnMaxLifetime":"0s","sqlMaxIdleConns":0,"sqlMaxOpenConns":0,"sslMode":""},"out_stordb_password":"","out_stordb_port":"3306","out_stordb_type":"mysql","out_stordb_user":"cgrates","users_filters":null},"radius_agent":{"client_dictionaries":{"*default":"/usr/share/cgrates/radius/dict/"},"client_secrets":{"*default":"CGRateS.org"},"enabled":false,"listen_acct":"127.0.0.1:1813","listen_auth":"127.0.0.1:1812","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"]},"rates":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*intervalStart":[],"*profileIDs":[],"*profileIgnoreFilters":[],"*startTime":[],"*usage":[]},"prefix_indexed_fields":[],"rate_exists_indexed_fields":[],"rate_indexed_selects":true,"rate_nested_fields":false,"rate_notexists_indexed_fields":[],"rate_prefix_indexed_fields":[],"rate_suffix_indexed_fields":[],"suffix_indexed_fields":[],"verbosity":1000},"registrarc":{"dispatchers":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]},"rpc":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]}},"resources":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*units":[],"*usageID":[],"*usageTTL":[]},"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[],"thresholds_conns":[]},"routes":{"accounts_conns":[],"attributes_conns":[],"default_ratio":1,"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*context":[],"*ignoreErrors":[],"*limit":[],"*maxCost":[],"*offset":[],"*profileCount":[],"*usage":[]},"prefix_indexed_fields":[],"rates_conns":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"rpc_conns":{"*bijson_localhost":{"conns":[{"address":"127.0.0.1:2014","transport":"*birpc_json"}],"poolSize":0,"strategy":"*first"},"*birpc_internal":{"conns":[{"address":"*birpc_internal","transport":""}],"poolSize":0,"strategy":"*first"},"*internal":{"conns":[{"address":"*internal","transport":""}],"poolSize":0,"strategy":"*first"},"*localhost":{"conns":[{"address":"127.0.0.1:2012","transport":"*json"}],"poolSize":0,"strategy":"*first"}},"sessions":{"accounts_conns":[],"actions_conns":[],"alterable_fields":[],"attributes_conns":[],"cdrs_conns":[],"channel_sync_interval":"0","chargers_conns":[],"client_protocol":1,"default_usage":{"*any":"3h0m0s","*data":"1048576","*sms":"1","*voice":"3h0m0s"},"enabled":false,"listen_bigob":"","listen_bijson":"127.0.0.1:2014","min_dur_low_balance":"0","opts":{"*accountS":[],"*attributeS":[],"*attributesDerivedReply":[],"*blockerError":[],"*cdrS":[],"*cdrsDerivedReply":[],"*chargeable":[],"*chargerS":[],"*debitInterval":[],"*forceDuration":[],"*initiate":[],"*maxUsage":[],"*message":[],"*resourceS":[],"*resourcesAllocate":[],"*resourcesAuthorize":[],"*resourcesDerivedReply":[],"*resourcesRelease":[],"*routeS":[],"*routesDerivedReply":[],"*statS":[],"*statsDerivedReply":[],"*terminate":[],"*thresholdS":[],"*thresholdsDerivedReply":[],"*ttl":[],"*ttlLastUsage":[],"*ttlLastUsed":[],"*ttlMaxDelay":[],"*ttlUsage":[],"*update":[]},"rates_conns":[],"replication_conns":[],"resources_conns":[],"routes_conns":[],"session_indexes":[],"stats_conns":[],"stir":{"allowed_attest":["*any"],"default_attest":"A","payload_maxduration":"-1","privatekey_path":"","publickey_path":""},"store_session_costs":false,"terminate_attempts":5,"thresholds_conns":[]},"sip_agent":{"enabled":false,"listen":"127.0.0.1:5060","listen_net":"udp","request_processors":[],"retransmission_timer":"1s","sessions_conns":["*internal"],"timezone":""},"stats":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[],"*roundingDecimals":[]},"prefix_indexed_fields":[],"store_interval":"","store_uncompressed_limit":0,"suffix_indexed_fields":[],"thresholds_conns":[]},"stor_db":{"db_host":"127.0.0.1","db_name":"cgrates","db_password":"","db_port":3306,"db_type":"*mysql","db_user":"cgrates","items":{"*cdrs":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*session_costs":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_attributes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_chargers":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_dispatcher_hosts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_dispatcher_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_routes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_stats":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoQueryTimeout":"10s","mysqlLocation":"Local","sqlConnMaxLifetime":"0s","sqlMaxIdleConns":10,"sqlMaxOpenConns":100,"sslMode":"disable"},"prefix_indexed_fields":[],"remote_conns":null,"replication_conns":null,"string_indexed_fields":[]},"suretax":{"bill_to_number":"","business_unit":"","client_number":"","client_tracking":"~*req.CGRID","customer_number":"~*req.Subject","include_local_cost":false,"orig_number":"~*req.Subject","p2pplus4":"","p2pzipcode":"","plus4":"","regulatory_code":"03","response_group":"03","response_type":"D4","return_file_code":"0","sales_type_code":"R","tax_exemption_code_list":"","tax_included":"0","tax_situs_rule":"04","term_number":"~*req.Destination","timezone":"UTC","trans_type_code":"010101","unit_type":"00","units":"1","url":"","validation_key":"","zipcode":""},"templates":{"*asr":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"}],"*cca":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"path":"*rep.Result-Code","tag":"ResultCode","type":"*constant","value":"2001"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"},{"mandatory":true,"path":"*rep.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"mandatory":true,"path":"*rep.CC-Request-Type","tag":"CCRequestType","type":"*variable","value":"~*req.CC-Request-Type"},{"mandatory":true,"path":"*rep.CC-Request-Number","tag":"CCRequestNumber","type":"*variable","value":"~*req.CC-Request-Number"}],"*cdrLog":[{"mandatory":true,"path":"*cdr.ToR","tag":"ToR","type":"*variable","value":"~*req.BalanceType"},{"mandatory":true,"path":"*cdr.OriginHost","tag":"OriginHost","type":"*constant","value":"127.0.0.1"},{"mandatory":true,"path":"*cdr.RequestType","tag":"RequestType","type":"*constant","value":"*none"},{"mandatory":true,"path":"*cdr.Tenant","tag":"Tenant","type":"*variable","value":"~*req.Tenant"},{"mandatory":true,"path":"*cdr.Account","tag":"Account","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Subject","tag":"Subject","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Cost","tag":"Cost","type":"*variable","value":"~*req.Cost"},{"mandatory":true,"path":"*cdr.Source","tag":"Source","type":"*constant","value":"*cdrLog"},{"mandatory":true,"path":"*cdr.Usage","tag":"Usage","type":"*constant","value":"1"},{"mandatory":true,"path":"*cdr.RunID","tag":"RunID","type":"*variable","value":"~*req.ActionType"},{"mandatory":true,"path":"*cdr.SetupTime","tag":"SetupTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.AnswerTime","tag":"AnswerTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.PreRated","tag":"PreRated","type":"*constant","value":"true"}],"*err":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"}],"*errSip":[{"mandatory":true,"path":"*rep.Request","tag":"Request","type":"*constant","value":"SIP/2.0 500 Internal Server Error"}],"*rar":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"path":"*diamreq.Re-Auth-Request-Type","tag":"ReAuthRequestType","type":"*constant","value":"0"}]},"thresholds":{"actions_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[]},"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[]},"tls":{"ca_certificate":"","client_certificate":"","client_key":"","server_certificate":"","server_key":"","server_name":"","server_policy":4}}` + expected := `{"accounts":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"max_iterations":1000,"max_usage":"259200000000000","nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[],"*usage":[]},"prefix_indexed_fields":[],"rates_conns":[],"suffix_indexed_fields":[],"thresholds_conns":[]},"actions":{"accounts_conns":[],"cdrs_conns":[],"dynaprepaid_actionprofile":[],"ees_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[]},"prefix_indexed_fields":[],"stats_conns":[],"suffix_indexed_fields":[],"tenants":[],"thresholds_conns":[]},"admins":{"actions_conns":[],"attributes_conns":[],"caches_conns":["*internal"],"ees_conns":[],"enabled":false},"analyzers":{"cleanup_interval":"1h0m0s","db_path":"/var/spool/cgrates/analyzers","enabled":false,"index_type":"*scorch","ttl":"24h0m0s"},"apiban":{"enabled":false,"keys":[]},"asterisk_agent":{"asterisk_conns":[{"address":"127.0.0.1:8088","alias":"","connect_attempts":3,"password":"CGRateS.org","reconnects":5,"user":"cgrates"}],"create_cdr":false,"enabled":false,"sessions_conns":["*birpc_internal"]},"attributes":{"accounts_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*processRuns":[],"*profileIDs":[],"*profileIgnoreFilters":[],"*profileRuns":[]},"prefix_indexed_fields":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*apiban":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*caps_events":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*cdr_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*charger_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*closed_sessions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_loads":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatcher_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*event_charges":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*replication_hosts":{"limit":0,"precache":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rpc_connections":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*rpc_responses":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*stat_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*stir":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false},"*uch":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"}},"replication_conns":[]},"cdrs":{"accounts_conns":[],"actions_conns":[],"attributes_conns":[],"chargers_conns":[],"ees_conns":[],"enabled":false,"extra_fields":[],"online_cdr_exports":null,"opts":{"*accountS":[],"*attributeS":[],"*chargerS":[],"*eeS":[],"*rateS":[],"*statS":[],"*thresholdS":[]},"rates_conns":[],"session_cost_retries":5,"stats_conns":[],"store_cdrs":true,"thresholds_conns":[]},"chargers":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"config_db":{"db_host":"","db_name":"","db_password":"","db_port":0,"db_type":"*internal","db_user":"","opts":{"mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisSentinel":"","redisTLS":false}},"configs":{"enabled":false,"root_dir":"/var/spool/cgrates/configs","url":"/configs/"},"cores":{"caps":0,"caps_stats_interval":"0","caps_strategy":"*busy","ees_conns":[],"shutdown_timeout":"1s"},"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*account_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*actions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*attribute_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*charger_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_hosts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*dispatcher_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*load_ids":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profile_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resource_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*reverse_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*route_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*stat_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueue_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*statqueues":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_filter_indexes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*threshold_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false},"diameter_agent":{"asr_template":"","concurrent_requests":-1,"dictionaries_path":"/usr/share/cgrates/diameter/dict/","enabled":false,"forced_disconnect":"*none","listen":"127.0.0.1:3868","listen_net":"tcp","origin_host":"CGR-DA","origin_realm":"cgrates.org","product_name":"CGRateS","rar_template":"","request_processors":[],"sessions_conns":["*birpc_internal"],"synced_conn_requests":false,"vendor_id":0},"dispatchers":{"attributes_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"dns_agent":{"enabled":false,"listen":"127.0.0.1:2053","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"],"timezone":""},"ees":{"attributes_conns":[],"cache":{"*fileCSV":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"enabled":false,"exporters":[{"attempts":1,"attribute_context":"","attribute_ids":[],"concurrent_requests":0,"export_path":"/var/spool/cgrates/ees","failed_posts_dir":"/var/spool/cgrates/failed_posts","fields":[],"filters":[],"flags":[],"id":"*default","opts":{},"synchronous":false,"timezone":"","type":"*none"}]},"ers":{"enabled":false,"partial_cache_ttl":"1s","readers":[{"cache_dump_fields":[],"concurrent_requests":1024,"fields":[{"mandatory":true,"path":"*cgreq.ToR","tag":"ToR","type":"*variable","value":"~*req.2"},{"mandatory":true,"path":"*cgreq.OriginID","tag":"OriginID","type":"*variable","value":"~*req.3"},{"mandatory":true,"path":"*cgreq.RequestType","tag":"RequestType","type":"*variable","value":"~*req.4"},{"mandatory":true,"path":"*cgreq.Tenant","tag":"Tenant","type":"*variable","value":"~*req.6"},{"mandatory":true,"path":"*cgreq.Category","tag":"Category","type":"*variable","value":"~*req.7"},{"mandatory":true,"path":"*cgreq.Account","tag":"Account","type":"*variable","value":"~*req.8"},{"mandatory":true,"path":"*cgreq.Subject","tag":"Subject","type":"*variable","value":"~*req.9"},{"mandatory":true,"path":"*cgreq.Destination","tag":"Destination","type":"*variable","value":"~*req.10"},{"mandatory":true,"path":"*cgreq.SetupTime","tag":"SetupTime","type":"*variable","value":"~*req.11"},{"mandatory":true,"path":"*cgreq.AnswerTime","tag":"AnswerTime","type":"*variable","value":"~*req.12"},{"mandatory":true,"path":"*cgreq.Usage","tag":"Usage","type":"*variable","value":"~*req.13"}],"filters":[],"flags":[],"id":"*default","opts":{"csvFieldSeparator":",","csvHeaderDefineChar":":","csvRowLength":0,"natsSubject":"cgrates_cdrs","partialCacheAction":"*none","partialOrderField":"~*req.AnswerTime","xmlRootPath":""},"partial_commit_fields":[],"processed_path":"/var/spool/cgrates/ers/out","run_delay":"0","source_path":"/var/spool/cgrates/ers/in","tenant":"","timezone":"","type":"*none"}],"sessions_conns":["*internal"]},"filters":{"accounts_conns":[],"resources_conns":[],"stats_conns":[]},"freeswitch_agent":{"create_cdr":false,"empty_balance_ann_file":"","empty_balance_context":"","enabled":false,"event_socket_conns":[{"address":"127.0.0.1:8021","alias":"127.0.0.1:8021","password":"ClueCon","reconnects":5}],"extra_fields":[],"low_balance_ann_file":"","max_wait_connection":"2s","sessions_conns":["*birpc_internal"],"subscribe_park":true},"general":{"connect_attempts":5,"connect_timeout":"1s","dbdata_encoding":"*msgpack","decimal_max_scale":0,"decimal_min_scale":0,"decimal_precision":0,"decimal_rounding_mode":"ToNearestEven","default_caching":"*reload","default_category":"call","default_request_type":"*rated","default_tenant":"cgrates.org","default_timezone":"Local","digest_equal":":","digest_separator":",","failed_posts_dir":"/var/spool/cgrates/failed_posts","failed_posts_ttl":"5s","locking_timeout":"0","log_level":6,"logger":"*syslog","max_parallel_conns":100,"node_id":"ENGINE1","poster_attempts":3,"reconnects":-1,"reply_timeout":"2s","rounding_decimals":5,"rsr_separator":";","tpexport_dir":"/var/spool/cgrates/tpe"},"http":{"auth_users":{},"client_opts":{"dialFallbackDelay":"300ms","dialKeepAlive":"30s","dialTimeout":"30s","disableCompression":false,"disableKeepAlives":false,"expectContinueTimeout":"0s","forceAttemptHttp2":true,"idleConnTimeout":"1m30s","maxConnsPerHost":0,"maxIdleConns":100,"maxIdleConnsPerHost":2,"responseHeaderTimeout":"0s","skipTLSVerification":false,"tlsHandshakeTimeout":"10s"},"freeswitch_cdrs_url":"/freeswitch_json","http_cdrs":"/cdr_http","json_rpc_url":"/jsonrpc","registrars_url":"/registrar","use_basic_auth":false,"ws_url":"/ws"},"http_agent":[],"kamailio_agent":{"create_cdr":false,"enabled":false,"evapi_conns":[{"address":"127.0.0.1:8448","alias":"","reconnects":5}],"sessions_conns":["*birpc_internal"],"timezone":""},"listen":{"http":"127.0.0.1:2080","http_tls":"127.0.0.1:2280","rpc_gob":"127.0.0.1:2013","rpc_gob_tls":"127.0.0.1:2023","rpc_json":"127.0.0.1:2012","rpc_json_tls":"127.0.0.1:2022"},"loader":{"actions_conns":["*localhost"],"caches_conns":["*localhost"],"data_path":"./","disable_reverse":false,"field_separator":",","gapi_credentials":".gapi/credentials.json","gapi_token":".gapi/token.json","tpid":""},"loaders":[{"action":"*store","cache":{"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*attributes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*chargers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*stats":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"AttributeFilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.4"},{"path":"Path","tag":"Path","type":"*variable","value":"~*req.5"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.6"},{"path":"Value","tag":"Value","type":"*variable","value":"~*req.7"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.8"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.6"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.7"},{"path":"MetricFilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionProfileIDs","tag":"ActionProfileIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.4"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.5"},{"path":"RouteID","tag":"RouteID","type":"*variable","value":"~*req.6"},{"path":"RouteFilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.7"},{"path":"RouteAccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.8"},{"path":"RouteRateProfileIDs","tag":"RouteRateProfileIDs","type":"*variable","value":"~*req.9"},{"path":"RouteResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.10"},{"path":"RouteStatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.11"},{"path":"RouteWeights","tag":"RouteWeights","type":"*variable","value":"~*req.12"},{"path":"RouteBlocker","tag":"RouteBlocker","type":"*variable","value":"~*req.13"},{"path":"RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.14"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.4"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.5"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.4"},{"path":"StrategyParameters","tag":"StrategyParameters","type":"*variable","value":"~*req.5"},{"path":"ConnID","tag":"ConnID","type":"*variable","value":"~*req.6"},{"path":"ConnFilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.7"},{"path":"ConnWeight","tag":"ConnWeight","type":"*variable","value":"~*req.8"},{"path":"ConnBlocker","tag":"ConnBlocker","type":"*variable","value":"~*req.9"},{"path":"ConnParameters","tag":"ConnParameters","type":"*variable","value":"~*req.10"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"ConnectAttempts","tag":"ConnectAttempts","type":"*variable","value":"~*req.4"},{"path":"Reconnects","tag":"Reconnects","type":"*variable","value":"~*req.5"},{"path":"ConnectTimeout","tag":"ConnectTimeout","type":"*variable","value":"~*req.6"},{"path":"ReplyTimeout","tag":"ReplyTimeout","type":"*variable","value":"~*req.7"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.8"},{"path":"ClientKey","tag":"ClientKey","type":"*variable","value":"~*req.9"},{"path":"ClientCertificate","tag":"ClientCertificate","type":"*variable","value":"~*req.10"},{"path":"CaCertificate","tag":"CaCertificate","type":"*variable","value":"~*req.11"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"path":"RateID","tag":"RateID","type":"*variable","value":"~*req.7"},{"path":"RateFilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"path":"RateActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"path":"RateWeights","tag":"RateWeights","type":"*variable","value":"~*req.10"},{"path":"RateBlocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"path":"RateIntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"path":"RateFixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"path":"RateRecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"path":"RateUnit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"path":"RateIncrement","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"Rates.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.4"},{"path":"TargetType","tag":"TargetType","type":"*variable","value":"~*req.5"},{"path":"TargetIDs","tag":"TargetIDs","type":"*variable","value":"~*req.6"},{"path":"ActionID","tag":"ActionID","type":"*variable","value":"~*req.7"},{"path":"ActionFilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.8"},{"path":"ActionBlocker","tag":"ActionBlocker","type":"*variable","value":"~*req.9"},{"path":"ActionTTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"path":"ActionType","tag":"ActionType","type":"*variable","value":"~*req.11"},{"path":"ActionOpts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"path":"ActionPath","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"path":"ActionValue","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"Actions.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weights","tag":"Weights","type":"*variable","value":"~*req.3"},{"path":"Opts","tag":"Opts","type":"*variable","value":"~*req.4"},{"path":"BalanceID","tag":"BalanceID","type":"*variable","value":"~*req.5"},{"path":"BalanceFilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.6"},{"path":"BalanceWeights","tag":"BalanceWeights","type":"*variable","value":"~*req.7"},{"path":"BalanceType","tag":"BalanceType","type":"*variable","value":"~*req.8"},{"path":"BalanceUnits","tag":"BalanceUnits","type":"*variable","value":"~*req.9"},{"path":"BalanceUnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.10"},{"path":"BalanceOpts","tag":"BalanceOpts","type":"*variable","value":"~*req.11"},{"path":"BalanceCostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.12"},{"path":"BalanceAttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.13"},{"path":"BalanceRateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.14"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.15"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"enabled":false,"field_separator":",","id":"*default","lockfile_path":".cgr.lck","opts":{"*cache":"","*forceLock":false,"*stopOnError":false,"*withIndex":true},"run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}],"migrator":{"out_datadb_encoding":"msgpack","out_datadb_host":"127.0.0.1","out_datadb_name":"10","out_datadb_opts":{"mongoQueryTimeout":"0s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0s","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"out_datadb_password":"","out_datadb_port":"6379","out_datadb_type":"redis","out_datadb_user":"cgrates","out_stordb_host":"127.0.0.1","out_stordb_name":"cgrates","out_stordb_opts":{"mongoQueryTimeout":"0s","mysqlLocation":"","sqlConnMaxLifetime":"0s","sqlMaxIdleConns":0,"sqlMaxOpenConns":0,"sslMode":""},"out_stordb_password":"","out_stordb_port":"3306","out_stordb_type":"mysql","out_stordb_user":"cgrates","users_filters":null},"radius_agent":{"client_dictionaries":{"*default":"/usr/share/cgrates/radius/dict/"},"client_secrets":{"*default":"CGRateS.org"},"enabled":false,"listen_acct":"127.0.0.1:1813","listen_auth":"127.0.0.1:1812","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"]},"rates":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*intervalStart":[],"*profileIDs":[],"*profileIgnoreFilters":[],"*startTime":[],"*usage":[]},"prefix_indexed_fields":[],"rate_exists_indexed_fields":[],"rate_indexed_selects":true,"rate_nested_fields":false,"rate_notexists_indexed_fields":[],"rate_prefix_indexed_fields":[],"rate_suffix_indexed_fields":[],"suffix_indexed_fields":[],"verbosity":1000},"registrarc":{"dispatchers":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]},"rpc":{"hosts":[],"refresh_interval":"5m0s","registrars_conns":[]}},"resources":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*units":[],"*usageID":[],"*usageTTL":[]},"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[],"thresholds_conns":[]},"routes":{"accounts_conns":[],"attributes_conns":[],"default_ratio":1,"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*context":[],"*ignoreErrors":[],"*limit":[],"*maxCost":[],"*offset":[],"*profileCount":[],"*usage":[]},"prefix_indexed_fields":[],"rates_conns":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"rpc_conns":{"*bijson_localhost":{"conns":[{"address":"127.0.0.1:2014","transport":"*birpc_json"}],"poolSize":0,"strategy":"*first"},"*birpc_internal":{"conns":[{"address":"*birpc_internal","transport":""}],"poolSize":0,"strategy":"*first"},"*internal":{"conns":[{"address":"*internal","transport":""}],"poolSize":0,"strategy":"*first"},"*localhost":{"conns":[{"address":"127.0.0.1:2012","transport":"*json"}],"poolSize":0,"strategy":"*first"}},"sessions":{"accounts_conns":[],"actions_conns":[],"alterable_fields":[],"attributes_conns":[],"cdrs_conns":[],"channel_sync_interval":"0","chargers_conns":[],"client_protocol":1,"default_usage":{"*any":"3h0m0s","*data":"1048576","*sms":"1","*voice":"3h0m0s"},"enabled":false,"listen_bigob":"","listen_bijson":"127.0.0.1:2014","min_dur_low_balance":"0","opts":{"*accountS":[],"*attributeS":[],"*attributesDerivedReply":[],"*blockerError":[],"*cdrS":[],"*cdrsDerivedReply":[],"*chargeable":[],"*chargerS":[],"*debitInterval":[],"*forceDuration":[],"*initiate":[],"*maxUsage":[],"*message":[],"*resourceS":[],"*resourcesAllocate":[],"*resourcesAuthorize":[],"*resourcesDerivedReply":[],"*resourcesRelease":[],"*routeS":[],"*routesDerivedReply":[],"*statS":[],"*statsDerivedReply":[],"*terminate":[],"*thresholdS":[],"*thresholdsDerivedReply":[],"*ttl":[],"*ttlLastUsage":[],"*ttlLastUsed":[],"*ttlMaxDelay":[],"*ttlUsage":[],"*update":[]},"rates_conns":[],"replication_conns":[],"resources_conns":[],"routes_conns":[],"session_indexes":[],"stats_conns":[],"stir":{"allowed_attest":["*any"],"default_attest":"A","payload_maxduration":"-1","privatekey_path":"","publickey_path":""},"store_session_costs":false,"terminate_attempts":5,"thresholds_conns":[]},"sip_agent":{"enabled":false,"listen":"127.0.0.1:5060","listen_net":"udp","request_processors":[],"retransmission_timer":"1s","sessions_conns":["*internal"],"timezone":""},"stats":{"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[],"*roundingDecimals":[]},"prefix_indexed_fields":[],"store_interval":"","store_uncompressed_limit":0,"suffix_indexed_fields":[],"thresholds_conns":[]},"stor_db":{"db_host":"127.0.0.1","db_name":"cgrates","db_password":"","db_port":3306,"db_type":"*mysql","db_user":"cgrates","items":{"*cdrs":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*session_costs":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_accounts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_action_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_attributes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_chargers":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_dispatcher_hosts":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_dispatcher_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_filters":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_rate_profiles":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_resources":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_routes":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_stats":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*tp_thresholds":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false},"*versions":{"limit":-1,"remote":false,"replicate":false,"static_ttl":false}},"opts":{"mongoQueryTimeout":"10s","mysqlLocation":"Local","sqlConnMaxLifetime":"0s","sqlMaxIdleConns":10,"sqlMaxOpenConns":100,"sslMode":"disable"},"prefix_indexed_fields":[],"remote_conns":null,"replication_conns":null,"string_indexed_fields":[]},"suretax":{"bill_to_number":"","business_unit":"","client_number":"","client_tracking":"~*req.CGRID","customer_number":"~*req.Subject","include_local_cost":false,"orig_number":"~*req.Subject","p2pplus4":"","p2pzipcode":"","plus4":"","regulatory_code":"03","response_group":"03","response_type":"D4","return_file_code":"0","sales_type_code":"R","tax_exemption_code_list":"","tax_included":"0","tax_situs_rule":"04","term_number":"~*req.Destination","timezone":"UTC","trans_type_code":"010101","unit_type":"00","units":"1","url":"","validation_key":"","zipcode":""},"templates":{"*asr":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"}],"*cca":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"path":"*rep.Result-Code","tag":"ResultCode","type":"*constant","value":"2001"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"},{"mandatory":true,"path":"*rep.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"mandatory":true,"path":"*rep.CC-Request-Type","tag":"CCRequestType","type":"*variable","value":"~*req.CC-Request-Type"},{"mandatory":true,"path":"*rep.CC-Request-Number","tag":"CCRequestNumber","type":"*variable","value":"~*req.CC-Request-Number"}],"*cdrLog":[{"mandatory":true,"path":"*cdr.ToR","tag":"ToR","type":"*variable","value":"~*req.BalanceType"},{"mandatory":true,"path":"*cdr.OriginHost","tag":"OriginHost","type":"*constant","value":"127.0.0.1"},{"mandatory":true,"path":"*cdr.RequestType","tag":"RequestType","type":"*constant","value":"*none"},{"mandatory":true,"path":"*cdr.Tenant","tag":"Tenant","type":"*variable","value":"~*req.Tenant"},{"mandatory":true,"path":"*cdr.Account","tag":"Account","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Subject","tag":"Subject","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Cost","tag":"Cost","type":"*variable","value":"~*req.Cost"},{"mandatory":true,"path":"*cdr.Source","tag":"Source","type":"*constant","value":"*cdrLog"},{"mandatory":true,"path":"*cdr.Usage","tag":"Usage","type":"*constant","value":"1"},{"mandatory":true,"path":"*cdr.RunID","tag":"RunID","type":"*variable","value":"~*req.ActionType"},{"mandatory":true,"path":"*cdr.SetupTime","tag":"SetupTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.AnswerTime","tag":"AnswerTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.PreRated","tag":"PreRated","type":"*constant","value":"true"}],"*err":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"}],"*errSip":[{"mandatory":true,"path":"*rep.Request","tag":"Request","type":"*constant","value":"SIP/2.0 500 Internal Server Error"}],"*rar":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"path":"*diamreq.Re-Auth-Request-Type","tag":"ReAuthRequestType","type":"*constant","value":"0"}]},"thresholds":{"actions_conns":[],"enabled":false,"exists_indexed_fields":[],"indexed_selects":true,"nested_fields":false,"notexists_indexed_fields":[],"opts":{"*profileIDs":[],"*profileIgnoreFilters":[]},"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[]},"tls":{"ca_certificate":"","client_certificate":"","client_key":"","server_certificate":"","server_key":"","server_name":"","server_policy":4}}` cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSON) if err != nil { t.Fatal(err) diff --git a/config/generalcfg.go b/config/generalcfg.go index be11d78ac..92223bf5e 100644 --- a/config/generalcfg.go +++ b/config/generalcfg.go @@ -24,6 +24,7 @@ import ( "github.com/cgrates/birpc/context" "github.com/cgrates/cgrates/utils" + "github.com/ericlagergren/decimal" ) // GeneralCfg is the general config section @@ -51,6 +52,11 @@ type GeneralCfg struct { DigestEqual string // RSRSep string // separator used to split RSRParser (by default is used ";") MaxParallelConns int // the maximum number of connections used by the *parallel strategy + + DecimalMaxScale int + DecimalMinScale int + DecimalPrecision int + DecimalRoundingMode decimal.RoundingMode } // loadGeneralCfg loads the General section of the configuration @@ -146,35 +152,51 @@ func (gencfg *GeneralCfg) loadFromJSONCfg(jsnGeneralCfg *GeneralJsonCfg) (err er gencfg.MaxParallelConns = *jsnGeneralCfg.Max_parallel_conns } - return nil + if jsnGeneralCfg.Decimal_max_scale != nil { + gencfg.DecimalMaxScale = *jsnGeneralCfg.Decimal_max_scale + } + if jsnGeneralCfg.Decimal_min_scale != nil { + gencfg.DecimalMinScale = *jsnGeneralCfg.Decimal_min_scale + } + if jsnGeneralCfg.Decimal_precision != nil { + gencfg.DecimalPrecision = *jsnGeneralCfg.Decimal_precision + } + if jsnGeneralCfg.Decimal_rounding_mode != nil { + gencfg.DecimalRoundingMode, err = utils.NewRoundingMode(*jsnGeneralCfg.Decimal_rounding_mode) + } + return } // AsMapInterface returns the config as a map[string]interface{} func (gencfg GeneralCfg) AsMapInterface(string) interface{} { mp := map[string]interface{}{ - utils.NodeIDCfg: gencfg.NodeID, - utils.LoggerCfg: gencfg.Logger, - utils.LogLevelCfg: gencfg.LogLevel, - utils.RoundingDecimalsCfg: gencfg.RoundingDecimals, - utils.DBDataEncodingCfg: utils.Meta + gencfg.DBDataEncoding, - utils.TpExportPathCfg: gencfg.TpExportPath, - utils.PosterAttemptsCfg: gencfg.PosterAttempts, - utils.FailedPostsDirCfg: gencfg.FailedPostsDir, - utils.DefaultReqTypeCfg: gencfg.DefaultReqType, - utils.DefaultCategoryCfg: gencfg.DefaultCategory, - utils.DefaultTenantCfg: gencfg.DefaultTenant, - utils.DefaultTimezoneCfg: gencfg.DefaultTimezone, - utils.DefaultCachingCfg: gencfg.DefaultCaching, - utils.ConnectAttemptsCfg: gencfg.ConnectAttempts, - utils.ReconnectsCfg: gencfg.Reconnects, - utils.DigestSeparatorCfg: gencfg.DigestSeparator, - utils.DigestEqualCfg: gencfg.DigestEqual, - utils.RSRSepCfg: gencfg.RSRSep, - utils.MaxParallelConnsCfg: gencfg.MaxParallelConns, - utils.LockingTimeoutCfg: "0", - utils.FailedPostsTTLCfg: "0", - utils.ConnectTimeoutCfg: "0", - utils.ReplyTimeoutCfg: "0", + utils.NodeIDCfg: gencfg.NodeID, + utils.LoggerCfg: gencfg.Logger, + utils.LogLevelCfg: gencfg.LogLevel, + utils.RoundingDecimalsCfg: gencfg.RoundingDecimals, + utils.DBDataEncodingCfg: utils.Meta + gencfg.DBDataEncoding, + utils.TpExportPathCfg: gencfg.TpExportPath, + utils.PosterAttemptsCfg: gencfg.PosterAttempts, + utils.FailedPostsDirCfg: gencfg.FailedPostsDir, + utils.DefaultReqTypeCfg: gencfg.DefaultReqType, + utils.DefaultCategoryCfg: gencfg.DefaultCategory, + utils.DefaultTenantCfg: gencfg.DefaultTenant, + utils.DefaultTimezoneCfg: gencfg.DefaultTimezone, + utils.DefaultCachingCfg: gencfg.DefaultCaching, + utils.ConnectAttemptsCfg: gencfg.ConnectAttempts, + utils.ReconnectsCfg: gencfg.Reconnects, + utils.DigestSeparatorCfg: gencfg.DigestSeparator, + utils.DigestEqualCfg: gencfg.DigestEqual, + utils.RSRSepCfg: gencfg.RSRSep, + utils.MaxParallelConnsCfg: gencfg.MaxParallelConns, + utils.LockingTimeoutCfg: "0", + utils.FailedPostsTTLCfg: "0", + utils.ConnectTimeoutCfg: "0", + utils.ReplyTimeoutCfg: "0", + utils.DecimalMaxScaleCfg: gencfg.DecimalMaxScale, + utils.DecimalMinScaleCfg: gencfg.DecimalMinScale, + utils.DecimalPrecisionCfg: gencfg.DecimalPrecision, + utils.DecimalRoundingModeCfg: gencfg.DecimalRoundingMode.String(), } if gencfg.LockingTimeout != 0 { @@ -202,29 +224,33 @@ func (gencfg GeneralCfg) CloneSection() Section { return gencfg.Clone() } // Clone returns a deep copy of GeneralCfg func (gencfg GeneralCfg) Clone() *GeneralCfg { return &GeneralCfg{ - NodeID: gencfg.NodeID, - Logger: gencfg.Logger, - LogLevel: gencfg.LogLevel, - RoundingDecimals: gencfg.RoundingDecimals, - DBDataEncoding: gencfg.DBDataEncoding, - TpExportPath: gencfg.TpExportPath, - PosterAttempts: gencfg.PosterAttempts, - FailedPostsDir: gencfg.FailedPostsDir, - FailedPostsTTL: gencfg.FailedPostsTTL, - DefaultReqType: gencfg.DefaultReqType, - DefaultCategory: gencfg.DefaultCategory, - DefaultTenant: gencfg.DefaultTenant, - DefaultTimezone: gencfg.DefaultTimezone, - DefaultCaching: gencfg.DefaultCaching, - ConnectAttempts: gencfg.ConnectAttempts, - Reconnects: gencfg.Reconnects, - ConnectTimeout: gencfg.ConnectTimeout, - ReplyTimeout: gencfg.ReplyTimeout, - LockingTimeout: gencfg.LockingTimeout, - DigestSeparator: gencfg.DigestSeparator, - DigestEqual: gencfg.DigestEqual, - RSRSep: gencfg.RSRSep, - MaxParallelConns: gencfg.MaxParallelConns, + NodeID: gencfg.NodeID, + Logger: gencfg.Logger, + LogLevel: gencfg.LogLevel, + RoundingDecimals: gencfg.RoundingDecimals, + DBDataEncoding: gencfg.DBDataEncoding, + TpExportPath: gencfg.TpExportPath, + PosterAttempts: gencfg.PosterAttempts, + FailedPostsDir: gencfg.FailedPostsDir, + FailedPostsTTL: gencfg.FailedPostsTTL, + DefaultReqType: gencfg.DefaultReqType, + DefaultCategory: gencfg.DefaultCategory, + DefaultTenant: gencfg.DefaultTenant, + DefaultTimezone: gencfg.DefaultTimezone, + DefaultCaching: gencfg.DefaultCaching, + ConnectAttempts: gencfg.ConnectAttempts, + Reconnects: gencfg.Reconnects, + ConnectTimeout: gencfg.ConnectTimeout, + ReplyTimeout: gencfg.ReplyTimeout, + LockingTimeout: gencfg.LockingTimeout, + DigestSeparator: gencfg.DigestSeparator, + DigestEqual: gencfg.DigestEqual, + RSRSep: gencfg.RSRSep, + MaxParallelConns: gencfg.MaxParallelConns, + DecimalMaxScale: gencfg.DecimalMaxScale, + DecimalMinScale: gencfg.DecimalMinScale, + DecimalPrecision: gencfg.DecimalPrecision, + DecimalRoundingMode: gencfg.DecimalRoundingMode, } } @@ -253,6 +279,11 @@ type GeneralJsonCfg struct { Digest_equal *string Rsr_separator *string Max_parallel_conns *int + + Decimal_max_scale *int + Decimal_min_scale *int + Decimal_precision *int + Decimal_rounding_mode *string } func diffGeneralJsonCfg(d *GeneralJsonCfg, v1, v2 *GeneralCfg) *GeneralJsonCfg { @@ -329,5 +360,17 @@ func diffGeneralJsonCfg(d *GeneralJsonCfg, v1, v2 *GeneralCfg) *GeneralJsonCfg { if v1.MaxParallelConns != v2.MaxParallelConns { d.Max_parallel_conns = utils.IntPointer(v2.MaxParallelConns) } + if v1.DecimalMaxScale != v2.DecimalMaxScale { + d.Decimal_max_scale = utils.IntPointer(v2.DecimalMaxScale) + } + if v1.DecimalMinScale != v2.DecimalMinScale { + d.Decimal_min_scale = utils.IntPointer(v2.DecimalMinScale) + } + if v1.DecimalPrecision != v2.DecimalPrecision { + d.Decimal_precision = utils.IntPointer(v2.DecimalPrecision) + } + if v1.DecimalRoundingMode != v2.DecimalRoundingMode { + d.Decimal_rounding_mode = utils.StringPointer(v2.DecimalRoundingMode.String()) + } return d } diff --git a/config/generalcfg_test.go b/config/generalcfg_test.go index 41ccf70ee..960d6e972 100644 --- a/config/generalcfg_test.go +++ b/config/generalcfg_test.go @@ -147,29 +147,33 @@ func TestGeneralCfgAsMapInterface(t *testing.T) { }, }` eMap := map[string]interface{}{ - utils.NodeIDCfg: "cgrates", - utils.LoggerCfg: "*syslog", - utils.LogLevelCfg: 6, - utils.RoundingDecimalsCfg: 5, - utils.DBDataEncodingCfg: "*msgpack", - utils.TpExportPathCfg: "/var/spool/cgrates/tpe", - utils.PosterAttemptsCfg: 3, - utils.FailedPostsDirCfg: "/var/spool/cgrates/failed_posts", - utils.FailedPostsTTLCfg: "5s", - utils.DefaultReqTypeCfg: "*rated", - utils.DefaultCategoryCfg: "call", - utils.DefaultTenantCfg: "cgrates.org", - utils.DefaultTimezoneCfg: "Local", - utils.DefaultCachingCfg: "*reload", - utils.ConnectAttemptsCfg: 5, - utils.ReconnectsCfg: -1, - utils.ConnectTimeoutCfg: "1s", - utils.ReplyTimeoutCfg: "2s", - utils.LockingTimeoutCfg: "1s", - utils.DigestSeparatorCfg: ",", - utils.DigestEqualCfg: ":", - utils.RSRSepCfg: ";", - utils.MaxParallelConnsCfg: 100, + utils.NodeIDCfg: "cgrates", + utils.LoggerCfg: "*syslog", + utils.LogLevelCfg: 6, + utils.RoundingDecimalsCfg: 5, + utils.DBDataEncodingCfg: "*msgpack", + utils.TpExportPathCfg: "/var/spool/cgrates/tpe", + utils.PosterAttemptsCfg: 3, + utils.FailedPostsDirCfg: "/var/spool/cgrates/failed_posts", + utils.FailedPostsTTLCfg: "5s", + utils.DefaultReqTypeCfg: "*rated", + utils.DefaultCategoryCfg: "call", + utils.DefaultTenantCfg: "cgrates.org", + utils.DefaultTimezoneCfg: "Local", + utils.DefaultCachingCfg: "*reload", + utils.ConnectAttemptsCfg: 5, + utils.ReconnectsCfg: -1, + utils.ConnectTimeoutCfg: "1s", + utils.ReplyTimeoutCfg: "2s", + utils.LockingTimeoutCfg: "1s", + utils.DigestSeparatorCfg: ",", + utils.DigestEqualCfg: ":", + utils.RSRSepCfg: ";", + utils.MaxParallelConnsCfg: 100, + utils.DecimalMaxScaleCfg: 0, + utils.DecimalMinScaleCfg: 0, + utils.DecimalPrecisionCfg: 0, + utils.DecimalRoundingModeCfg: "ToNearestEven", } if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil { t.Error(err) @@ -190,29 +194,33 @@ func TestGeneralCfgAsMapInterface1(t *testing.T) { } }` eMap := map[string]interface{}{ - utils.NodeIDCfg: "ENGINE1", - utils.LoggerCfg: "*syslog", - utils.LogLevelCfg: 6, - utils.RoundingDecimalsCfg: 5, - utils.DBDataEncodingCfg: "*msgpack", - utils.TpExportPathCfg: "/var/spool/cgrates/tpe", - utils.PosterAttemptsCfg: 3, - utils.FailedPostsDirCfg: "/var/spool/cgrates/failed_posts", - utils.FailedPostsTTLCfg: "0", - utils.DefaultReqTypeCfg: "*rated", - utils.DefaultCategoryCfg: "call", - utils.DefaultTenantCfg: "cgrates.org", - utils.DefaultTimezoneCfg: "Local", - utils.DefaultCachingCfg: "*reload", - utils.ConnectAttemptsCfg: 5, - utils.ReconnectsCfg: -1, - utils.ConnectTimeoutCfg: "0", - utils.ReplyTimeoutCfg: "0", - utils.LockingTimeoutCfg: "0", - utils.DigestSeparatorCfg: ",", - utils.DigestEqualCfg: ":", - utils.RSRSepCfg: ";", - utils.MaxParallelConnsCfg: 100, + utils.NodeIDCfg: "ENGINE1", + utils.LoggerCfg: "*syslog", + utils.LogLevelCfg: 6, + utils.RoundingDecimalsCfg: 5, + utils.DBDataEncodingCfg: "*msgpack", + utils.TpExportPathCfg: "/var/spool/cgrates/tpe", + utils.PosterAttemptsCfg: 3, + utils.FailedPostsDirCfg: "/var/spool/cgrates/failed_posts", + utils.FailedPostsTTLCfg: "0", + utils.DefaultReqTypeCfg: "*rated", + utils.DefaultCategoryCfg: "call", + utils.DefaultTenantCfg: "cgrates.org", + utils.DefaultTimezoneCfg: "Local", + utils.DefaultCachingCfg: "*reload", + utils.ConnectAttemptsCfg: 5, + utils.ReconnectsCfg: -1, + utils.ConnectTimeoutCfg: "0", + utils.ReplyTimeoutCfg: "0", + utils.LockingTimeoutCfg: "0", + utils.DigestSeparatorCfg: ",", + utils.DigestEqualCfg: ":", + utils.RSRSepCfg: ";", + utils.MaxParallelConnsCfg: 100, + utils.DecimalMaxScaleCfg: 0, + utils.DecimalMinScaleCfg: 0, + utils.DecimalPrecisionCfg: 0, + utils.DecimalRoundingModeCfg: "ToNearestEven", } if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil { t.Error(err) diff --git a/config/ratescfg_test.go b/config/ratescfg_test.go index f43fbacca..9988a7676 100644 --- a/config/ratescfg_test.go +++ b/config/ratescfg_test.go @@ -247,13 +247,13 @@ func TestDiffRateSJsonCfg(t *testing.T) { Usage: []*utils.DynamicDecimalBigOpt{ { Tenant: "cgrates.org", - Value: new(decimal.Big).SetUint64(2), + Value: decimal.WithContext(utils.DecimalContext).SetUint64(2), }, }, IntervalStart: []*utils.DynamicDecimalBigOpt{ { Tenant: "cgrates.org", - Value: new(decimal.Big).SetUint64(2), + Value: decimal.WithContext(utils.DecimalContext).SetUint64(2), }, }, ProfileIgnoreFilters: []*utils.DynamicBoolOpt{ @@ -294,13 +294,13 @@ func TestDiffRateSJsonCfg(t *testing.T) { Usage: []*utils.DynamicDecimalBigOpt{ { Tenant: "cgrates.net", - Value: new(decimal.Big).SetUint64(3), + Value: decimal.WithContext(utils.DecimalContext).SetUint64(3), }, }, IntervalStart: []*utils.DynamicDecimalBigOpt{ { Tenant: "cgrates.net", - Value: new(decimal.Big).SetUint64(3), + Value: decimal.WithContext(utils.DecimalContext).SetUint64(3), }, }, ProfileIgnoreFilters: []*utils.DynamicBoolOpt{ diff --git a/config/routescfg_test.go b/config/routescfg_test.go index 36fa4bad4..2f3736ac0 100644 --- a/config/routescfg_test.go +++ b/config/routescfg_test.go @@ -276,7 +276,7 @@ func TestDiffRouteSJsonCfg(t *testing.T) { Usage: []*utils.DynamicDecimalBigOpt{ { Tenant: "cgrates.net", - Value: new(decimal.Big).SetUint64(3), + Value: decimal.WithContext(utils.DecimalContext).SetUint64(3), }, }, }, @@ -329,7 +329,7 @@ func TestDiffRouteSJsonCfg(t *testing.T) { Usage: []*utils.DynamicDecimalBigOpt{ { Tenant: "cgrates.org", - Value: new(decimal.Big).SetUint64(2), + Value: decimal.WithContext(utils.DecimalContext).SetUint64(2), }, }, }, diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go index 6646d296c..d3503ed0f 100644 --- a/engine/storage_mongo_datadb.go +++ b/engine/storage_mongo_datadb.go @@ -153,7 +153,7 @@ func DecimalDecoder(ec bsoncodec.DecodeContext, vw bsonrw.ValueReader, val refle if err != nil { return err } - dBig := new(decimal.Big) + dBig := decimal.WithContext(utils.DecimalContext) if err := dBig.UnmarshalText(data); err != nil { return err } diff --git a/engine/z_onstor_it_test.go b/engine/z_onstor_it_test.go index b14e35bc9..897939ea6 100644 --- a/engine/z_onstor_it_test.go +++ b/engine/z_onstor_it_test.go @@ -1188,7 +1188,7 @@ func testOnStorITAccount(t *testing.T) { }, Type: utils.MetaVoice, Units: &utils.Decimal{ - Big: new(decimal.Big).SetUint64(10), + Big: decimal.WithContext(utils.DecimalContext).SetUint64(10), }, Opts: map[string]interface{}{ "key1": "val1", diff --git a/general_tests/all_cfg_rld_it_test.go b/general_tests/all_cfg_rld_it_test.go index beb5e3d83..4ac18eeed 100644 --- a/general_tests/all_cfg_rld_it_test.go +++ b/general_tests/all_cfg_rld_it_test.go @@ -111,7 +111,7 @@ func testConfigSReload(t *testing.T) { t.Errorf("Expected OK received: %s", reply) } - cfgStr := "{\"cores\":{\"caps\":0,\"caps_stats_interval\":\"0\",\"caps_strategy\":\"*busy\",\"shutdown_timeout\":\"1s\"}}" + cfgStr := "{\"cores\":{\"caps\":0,\"caps_stats_interval\":\"0\",\"caps_strategy\":\"*busy\",\"ees_conns\":[],\"shutdown_timeout\":\"1s\"}}" var rpl2 string if err := testRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{ Tenant: "cgrates.org", diff --git a/general_tests/all_sections_cfg_rld_it_test.go b/general_tests/all_sections_cfg_rld_it_test.go index 157d8d320..2a74963cc 100644 --- a/general_tests/all_sections_cfg_rld_it_test.go +++ b/general_tests/all_sections_cfg_rld_it_test.go @@ -176,7 +176,7 @@ func testSectConfigSReloadCores(t *testing.T) { } else if reply != utils.OK { t.Errorf("Expected OK received: %+v", reply) } - cfgStr := "{\"cores\":{\"caps\":0,\"caps_stats_interval\":\"0\",\"caps_strategy\":\"*busy\",\"shutdown_timeout\":\"1s\"}}" + cfgStr := "{\"cores\":{\"caps\":0,\"caps_stats_interval\":\"0\",\"caps_strategy\":\"*busy\",\"ees_conns\":[],\"shutdown_timeout\":\"1s\"}}" var rpl string if err := testSectRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{ Tenant: "cgrates.org", diff --git a/general_tests/config_reload_rates_it_test.go b/general_tests/config_reload_rates_it_test.go index 9de56e509..da79aa9f7 100644 --- a/general_tests/config_reload_rates_it_test.go +++ b/general_tests/config_reload_rates_it_test.go @@ -106,7 +106,7 @@ func testRateConfigSReloadRates(t *testing.T) { } else if reply != utils.OK { t.Errorf("Expected OK received: %+v", reply) } - cfgStr := "{\"rates\":{\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":false,\"opts\":{\"*intervalStart\":[],\"*profileIDs\":[],\"*profileIgnoreFilters\":[],\"*startTime\":[],\"*usage\":[]},\"prefix_indexed_fields\":[],\"rate_indexed_selects\":true,\"rate_nested_fields\":false,\"rate_prefix_indexed_fields\":[],\"rate_suffix_indexed_fields\":[],\"suffix_indexed_fields\":[],\"verbosity\":1000}}" + cfgStr := "{\"rates\":{\"enabled\":true,\"exists_indexed_fields\":[],\"indexed_selects\":true,\"nested_fields\":false,\"notexists_indexed_fields\":[],\"opts\":{\"*intervalStart\":[],\"*profileIDs\":[],\"*profileIgnoreFilters\":[],\"*startTime\":[],\"*usage\":[]},\"prefix_indexed_fields\":[],\"rate_exists_indexed_fields\":[],\"rate_indexed_selects\":true,\"rate_nested_fields\":false,\"rate_notexists_indexed_fields\":[],\"rate_prefix_indexed_fields\":[],\"rate_suffix_indexed_fields\":[],\"suffix_indexed_fields\":[],\"verbosity\":1000}}" var rpl string if err := testRateRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{ Tenant: "cgrates.org", diff --git a/general_tests/session_volume_discount_it_test.go b/general_tests/session_volume_discount_it_test.go index 738e867b5..bcd61b643 100644 --- a/general_tests/session_volume_discount_it_test.go +++ b/general_tests/session_volume_discount_it_test.go @@ -413,7 +413,7 @@ func testSessVolDiscAccountAfterDebiting(t *testing.T) { }, }, Type: "*abstract", - Units: &utils.Decimal{utils.SumDecimalAsBig(&utils.Decimal{utils.NewDecimal(0, 0).Neg(utils.NewDecimal(1, 0).Big)}, utils.NewDecimal(1, 0))}, // this should be -0 + Units: utils.SumDecimal(&utils.Decimal{utils.NewDecimal(0, 0).Neg(utils.NewDecimal(1, 0).Big)}, utils.NewDecimal(1, 0)), // this should be -0 CostIncrements: []*utils.CostIncrement{ { Increment: utils.NewDecimal(int64(time.Second), 0), @@ -430,7 +430,7 @@ func testSessVolDiscAccountAfterDebiting(t *testing.T) { }, }, Type: "*abstract", - Units: &utils.Decimal{utils.SumDecimalAsBig(&utils.Decimal{utils.NewDecimal(0, 0).Neg(utils.NewDecimal(1, 0).Big)}, utils.NewDecimal(1, 0))}, + Units: utils.SumDecimal(&utils.Decimal{utils.NewDecimal(0, 0).Neg(utils.NewDecimal(1, 0).Big)}, utils.NewDecimal(1, 0)), CostIncrements: []*utils.CostIncrement{ { Increment: utils.NewDecimal(int64(time.Second), 0), diff --git a/rates/rates.go b/rates/rates.go index ee90199f0..f183a51bf 100644 --- a/rates/rates.go +++ b/rates/rates.go @@ -204,7 +204,7 @@ func (rS *RateS) rateProfileCostForEvent(ctx *context.Context, rtPfl *utils.Rate return nil, err } rpCost.CostIntervals = make([]*utils.RateSIntervalCost, len(costIntervals)) - finalCost := new(decimal.Big) + finalCost := decimal.WithContext(utils.DecimalContext) for idx, costInt := range costIntervals { finalCost = utils.SumBig(finalCost, costInt.Cost(rpCost.Rates)) // sums the costs for all intervals rpCost.CostIntervals[idx] = costInt.AsRatesIntervalsCost() //this does not contains IncrementStart and IntervalStart so we convert in RatesIntervalCosts diff --git a/services/globalvars.go b/services/globalvars.go index c79d1fc98..3fafcf505 100644 --- a/services/globalvars.go +++ b/services/globalvars.go @@ -49,12 +49,20 @@ type GlobalVarS struct { func (gv *GlobalVarS) Start(*context.Context, context.CancelFunc) error { ees.SetFailedPostCacheTTL(gv.cfg.GeneralCfg().FailedPostsTTL) engine.SetHTTPPstrTransport(gv.cfg.HTTPCfg().ClientOpts) + utils.DecimalContext.MaxScale = gv.cfg.GeneralCfg().DecimalMaxScale + utils.DecimalContext.MinScale = gv.cfg.GeneralCfg().DecimalMinScale + utils.DecimalContext.Precision = gv.cfg.GeneralCfg().DecimalPrecision + utils.DecimalContext.RoundingMode = gv.cfg.GeneralCfg().DecimalRoundingMode return nil } // Reload handles the change of config func (gv *GlobalVarS) Reload(*context.Context, context.CancelFunc) error { engine.SetHTTPPstrTransport(gv.cfg.HTTPCfg().ClientOpts) + utils.DecimalContext.MaxScale = gv.cfg.GeneralCfg().DecimalMaxScale + utils.DecimalContext.MinScale = gv.cfg.GeneralCfg().DecimalMinScale + utils.DecimalContext.Precision = gv.cfg.GeneralCfg().DecimalPrecision + utils.DecimalContext.RoundingMode = gv.cfg.GeneralCfg().DecimalRoundingMode return nil } diff --git a/utils/account.go b/utils/account.go index 20ee58865..f2ef20622 100644 --- a/utils/account.go +++ b/utils/account.go @@ -61,7 +61,7 @@ func (ap *Account) AccountBalancesBackup() (abb AccountBalancesBackup) { if ap.Balances != nil { abb = make(AccountBalancesBackup) for blncID, blnc := range ap.Balances { - abb[blncID] = new(decimal.Big).Copy(blnc.Units.Big) + abb[blncID] = CloneDecimalBig(blnc.Units.Big) } } return diff --git a/utils/consts.go b/utils/consts.go index 65ae8c223..90fd707cb 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -1686,30 +1686,34 @@ var ( // GeneralCfg const ( - NodeIDCfg = "node_id" - LoggerCfg = "logger" - LogLevelCfg = "log_level" - RoundingDecimalsCfg = "rounding_decimals" - DBDataEncodingCfg = "dbdata_encoding" - TpExportPathCfg = "tpexport_dir" - PosterAttemptsCfg = "poster_attempts" - FailedPostsDirCfg = "failed_posts_dir" - FailedPostsTTLCfg = "failed_posts_ttl" - DefaultReqTypeCfg = "default_request_type" - DefaultCategoryCfg = "default_category" - DefaultTenantCfg = "default_tenant" - DefaultTimezoneCfg = "default_timezone" - DefaultCachingCfg = "default_caching" - ConnectAttemptsCfg = "connect_attempts" - ReconnectsCfg = "reconnects" - ConnectTimeoutCfg = "connect_timeout" - ReplyTimeoutCfg = "reply_timeout" - LockingTimeoutCfg = "locking_timeout" - DigestSeparatorCfg = "digest_separator" - DigestEqualCfg = "digest_equal" - RSRSepCfg = "rsr_separator" - MaxParallelConnsCfg = "max_parallel_conns" - EEsConnsCfg = "ees_conns" + NodeIDCfg = "node_id" + LoggerCfg = "logger" + LogLevelCfg = "log_level" + RoundingDecimalsCfg = "rounding_decimals" + DBDataEncodingCfg = "dbdata_encoding" + TpExportPathCfg = "tpexport_dir" + PosterAttemptsCfg = "poster_attempts" + FailedPostsDirCfg = "failed_posts_dir" + FailedPostsTTLCfg = "failed_posts_ttl" + DefaultReqTypeCfg = "default_request_type" + DefaultCategoryCfg = "default_category" + DefaultTenantCfg = "default_tenant" + DefaultTimezoneCfg = "default_timezone" + DefaultCachingCfg = "default_caching" + ConnectAttemptsCfg = "connect_attempts" + ReconnectsCfg = "reconnects" + ConnectTimeoutCfg = "connect_timeout" + ReplyTimeoutCfg = "reply_timeout" + LockingTimeoutCfg = "locking_timeout" + DigestSeparatorCfg = "digest_separator" + DigestEqualCfg = "digest_equal" + RSRSepCfg = "rsr_separator" + MaxParallelConnsCfg = "max_parallel_conns" + EEsConnsCfg = "ees_conns" + DecimalMaxScaleCfg = "decimal_max_scale" + DecimalMinScaleCfg = "decimal_min_scale" + DecimalPrecisionCfg = "decimal_precision" + DecimalRoundingModeCfg = "decimal_rounding_mode" ) // StorDbCfg diff --git a/utils/decimal.go b/utils/decimal.go index ee6ebc140..7073569c7 100644 --- a/utils/decimal.go +++ b/utils/decimal.go @@ -29,42 +29,55 @@ import ( ) var ( - DecimalNaN = &Decimal{} + DecimalNaN = &Decimal{} + DecimalContext decimal.Context ) func init() { - d, _ := new(decimal.Big).SetString("NaN") + d, _ := decimal.WithContext(DecimalContext).SetString("NaN") DecimalNaN = &Decimal{d} } +func NewRoundingMode(rnd string) (decimal.RoundingMode, error) { + switch rnd { + case decimal.ToNearestEven.String(): + return decimal.ToNearestEven, nil + case decimal.ToNearestAway.String(): + return decimal.ToNearestAway, nil + case decimal.ToZero.String(): + return decimal.ToZero, nil + case decimal.AwayFromZero.String(): + return decimal.AwayFromZero, nil + case decimal.ToNegativeInf.String(): + return decimal.ToNegativeInf, nil + case decimal.ToPositiveInf.String(): + return decimal.ToPositiveInf, nil + case decimal.ToNearestTowardZero.String(): + return decimal.ToNearestTowardZero, nil + default: + return 7, fmt.Errorf("usupoorted rounding: <%q>", rnd) + } +} + func DivideBig(x, y *decimal.Big) *decimal.Big { - if x == nil { + if x == nil || y == nil { return nil } - if y == nil { - return nil - } - return new(decimal.Big).Quo(x, y) + return decimal.WithContext(DecimalContext).Quo(x, y) } func DivideBigWithReminder(x, y *decimal.Big) (q *decimal.Big, r *decimal.Big) { - if x == nil { + if x == nil || y == nil { return } - if y == nil { - return - } - return new(decimal.Big).QuoRem(x, y, new(decimal.Big)) + return decimal.WithContext(DecimalContext).QuoRem(x, y, decimal.WithContext(DecimalContext)) } func MultiplyBig(x, y *decimal.Big) *decimal.Big { - if x == nil { + if x == nil || y == nil { return nil } - if y == nil { - return nil - } - return new(decimal.Big).Mul(x, y) + return decimal.WithContext(DecimalContext).Mul(x, y) } func SumBig(x, y *decimal.Big) *decimal.Big { @@ -74,51 +87,45 @@ func SumBig(x, y *decimal.Big) *decimal.Big { if y == nil { return x } - return new(decimal.Big).Add(x, y) + return decimal.WithContext(DecimalContext).Add(x, y) } func SubstractBig(x, y *decimal.Big) *decimal.Big { if x == nil || y == nil { return x } - return new(decimal.Big).Sub(x, y) + return decimal.WithContext(DecimalContext).Sub(x, y) } // MultiplyDecimal multiples two Decimals and returns the result func MultiplyDecimal(x, y *Decimal) *Decimal { - return &Decimal{new(decimal.Big).Mul(x.Big, y.Big)} + return &Decimal{MultiplyBig(x.Big, y.Big)} } // DivideDecimal divides two Decimals and returns the result func DivideDecimal(x, y *Decimal) *Decimal { - return &Decimal{new(decimal.Big).Quo(x.Big, y.Big)} + return &Decimal{DivideBig(x.Big, y.Big)} } // sumDecimal adds two Decimals and returns the result func SumDecimal(x, y *Decimal) *Decimal { - return &Decimal{new(decimal.Big).Add(x.Big, y.Big)} + if x == nil { + return y + } + if y == nil { + return x + } + return &Decimal{SumBig(x.Big, y.Big)} } func SubstractDecimal(x, y *Decimal) *Decimal { - return &Decimal{new(decimal.Big).Sub(x.Big, y.Big)} -} - -// SumDecimalAsBig returns tbe Big sum, protecting against nil Decimals -func SumDecimalAsBig(x, y *Decimal) *decimal.Big { - var xBig, yBig *decimal.Big - if x != nil { - xBig = x.Big - } - if y != nil { - yBig = y.Big - } - return SumBig(xBig, yBig) + return &Decimal{SubstractBig(x.Big, y.Big)} } // NewDecimalFromFloat64 is a constructor for Decimal out of float64 // passing through string is necessary due to differences between decimal and binary representation of float64 func NewDecimalFromFloat64(f float64) *Decimal { - d, _ := new(decimal.Big).SetString(strconv.FormatFloat(f, 'f', -1, 64)) + d, _ := decimal.WithContext(DecimalContext).SetString(strconv.FormatFloat(f, 'f', -1, 64)) return &Decimal{d} } @@ -129,7 +136,9 @@ func NewDecimalFromUsage(u string) (d *Decimal, err error) { case u == EmptyString: d = NewDecimal(0, 0) //"ns", "us" (or "µs"), "ms", "s", "m", "h" - case strings.HasSuffix(u, SSuffix), strings.HasSuffix(u, MSuffix), strings.HasSuffix(u, HSuffix): + case strings.HasSuffix(u, SSuffix), + strings.HasSuffix(u, MSuffix), + strings.HasSuffix(u, HSuffix): var tm time.Duration if tm, err = time.ParseDuration(u); err != nil { return @@ -143,7 +152,7 @@ func NewDecimalFromUsage(u string) (d *Decimal, err error) { // NewDecimal is a constructor for Decimal, following the one of decimal.Big func NewDecimal(value int64, scale int) *Decimal { - return &Decimal{decimal.New(value, scale)} + return &Decimal{decimal.WithContext(DecimalContext).SetMantScale(value, scale)} } type Decimal struct { @@ -153,10 +162,10 @@ type Decimal struct { // UnmarshalBinary implements the method for binaryUnmarshal interface for Msgpack encoding func (d *Decimal) UnmarshalBinary(data []byte) (err error) { if d == nil { - d = &Decimal{new(decimal.Big)} + d = &Decimal{decimal.WithContext(DecimalContext)} } if d.Big == nil { - d.Big = new(decimal.Big) + d.Big = decimal.WithContext(DecimalContext) } return d.Big.UnmarshalText(data) } @@ -164,7 +173,7 @@ func (d *Decimal) UnmarshalBinary(data []byte) (err error) { // MarshalBinary implements the method for binaryMarshal interface for Msgpack encoding func (d *Decimal) MarshalBinary() ([]byte, error) { if d.Big == nil { - d.Big = new(decimal.Big) + d.Big = decimal.WithContext(DecimalContext) } return d.Big.MarshalText() } @@ -172,10 +181,10 @@ func (d *Decimal) MarshalBinary() ([]byte, error) { // UnmarshalJSON implements the method for jsonUnmarshal for JSON encoding func (d *Decimal) UnmarshalJSON(data []byte) (err error) { if d == nil { - d = &Decimal{new(decimal.Big)} + d = &Decimal{decimal.WithContext(DecimalContext)} } if d.Big == nil { - d.Big = new(decimal.Big) + d.Big = decimal.WithContext(DecimalContext) } return d.Big.UnmarshalText(data) } @@ -191,7 +200,7 @@ func (d *Decimal) MarshalJSON() ([]byte, error) { // Clone returns a copy of the Decimal func (d *Decimal) Clone() *Decimal { - return &Decimal{new(decimal.Big).Copy(d.Big)} + return &Decimal{decimal.WithContext(DecimalContext).Copy(d.Big)} } // Compare wraps the decimal.Big.Cmp function. It does not handle nil d2 @@ -201,7 +210,7 @@ func (d *Decimal) Compare(d2 *Decimal) int { // NewDecimalFromString converts a string to decimal func NewDecimalFromString(value string) (*Decimal, error) { - z, ok := new(decimal.Big).SetString(value) + z, ok := decimal.WithContext(DecimalContext).SetString(value) // verify ok and check if the value was converted successfuly // and the big is a valid number if !ok || z.IsNaN(0) { @@ -234,3 +243,7 @@ func (d *Decimal) Duration() (dur time.Duration, ok bool) { dur = time.Duration(i64) return } + +func CloneDecimalBig(in *decimal.Big) *decimal.Big { + return decimal.WithContext(DecimalContext).Copy(in) +} diff --git a/utils/decimal_test.go b/utils/decimal_test.go index 7c5e39597..ae396dd20 100644 --- a/utils/decimal_test.go +++ b/utils/decimal_test.go @@ -44,9 +44,9 @@ func TestConvertDecimalToFloat(t *testing.T) { } func TestNewDecimalDivide(t *testing.T) { - x := new(decimal.Big).SetUint64(10) - y := new(decimal.Big).SetUint64(5) - expected, _ := new(decimal.Big).SetUint64(2).Float64() + x := decimal.WithContext(DecimalContext).SetUint64(10) + y := decimal.WithContext(DecimalContext).SetUint64(5) + expected, _ := decimal.WithContext(DecimalContext).SetUint64(2).Float64() received, _ := DivideBig(x, y).Float64() if !reflect.DeepEqual(expected, received) { t.Errorf("Expecting: <%+v>, received: <%+v>", expected, received) @@ -63,7 +63,7 @@ func TestDivideBigNil(t *testing.T) { t.Errorf("Expecting: <%+v>, received: <%+v>", expected, received) } - x = new(decimal.Big).SetUint64(2) + x = decimal.WithContext(DecimalContext).SetUint64(2) y = nil expected = nil received = DivideBig(x, y) @@ -73,9 +73,9 @@ func TestDivideBigNil(t *testing.T) { } func TestNewDecimalMultiply(t *testing.T) { - x := new(decimal.Big).SetUint64(10) - y := new(decimal.Big).SetUint64(5) - expected, _ := new(decimal.Big).SetUint64(50).Float64() + x := decimal.WithContext(DecimalContext).SetUint64(10) + y := decimal.WithContext(DecimalContext).SetUint64(5) + expected, _ := decimal.WithContext(DecimalContext).SetUint64(50).Float64() received, _ := MultiplyBig(x, y).Float64() if !reflect.DeepEqual(expected, received) { t.Errorf("Expecting: <%+v>, received: <%+v>", expected, received) @@ -92,7 +92,7 @@ func TestMultiplyBigNil(t *testing.T) { t.Errorf("Expecting: <%+v>, received: <%+v>", expected, received) } - x = new(decimal.Big).SetUint64(2) + x = decimal.WithContext(DecimalContext).SetUint64(2) y = nil expected = nil received = MultiplyBig(x, y) @@ -102,9 +102,9 @@ func TestMultiplyBigNil(t *testing.T) { } func TestNewDecimalAdd(t *testing.T) { - x := new(decimal.Big).SetUint64(10) - y := new(decimal.Big).SetUint64(5) - expected, _ := new(decimal.Big).SetUint64(15).Float64() + x := decimal.WithContext(DecimalContext).SetUint64(10) + y := decimal.WithContext(DecimalContext).SetUint64(5) + expected, _ := decimal.WithContext(DecimalContext).SetUint64(15).Float64() received, _ := SumBig(x, y).Float64() if !reflect.DeepEqual(expected, received) { t.Errorf("Expecting: <%+v>, received: <%+v>", expected, received) @@ -114,16 +114,16 @@ func TestNewDecimalAdd(t *testing.T) { func TestSumBigNil(t *testing.T) { var x, y, expected *decimal.Big x = nil - y = new(decimal.Big).SetUint64(2) - expected = new(decimal.Big).SetUint64(2) + y = decimal.WithContext(DecimalContext).SetUint64(2) + expected = decimal.WithContext(DecimalContext).SetUint64(2) received := SumBig(x, y) if !reflect.DeepEqual(expected, received) { t.Errorf("Expecting: <%+v>, received: <%+v>", expected, received) } - x = new(decimal.Big).SetUint64(3) + x = decimal.WithContext(DecimalContext).SetUint64(3) y = nil - expected = new(decimal.Big).SetUint64(3) + expected = decimal.WithContext(DecimalContext).SetUint64(3) received = SumBig(x, y) if !reflect.DeepEqual(expected, received) { t.Errorf("Expecting: <%+v>, received: <%+v>", expected, received) @@ -132,9 +132,9 @@ func TestSumBigNil(t *testing.T) { func TestSubstractBigNil(t *testing.T) { var x, y, expected *decimal.Big - x = new(decimal.Big).SetUint64(10) + x = decimal.WithContext(DecimalContext).SetUint64(10) y = nil - expected = new(decimal.Big).SetUint64(10) + expected = decimal.WithContext(DecimalContext).SetUint64(10) received := SubstractBig(x, y) if !reflect.DeepEqual(expected, received) { t.Errorf("Expecting: <%+v>, received: <%+v>", expected, received) @@ -290,10 +290,10 @@ func TestDecimalNewDecimalFromStringErr(t *testing.T) { } func TestDivideBigWithReminder(t *testing.T) { - x := new(decimal.Big).SetUint64(10) - y := new(decimal.Big).SetUint64(5) - qExpected := new(decimal.Big).SetUint64(2) - rExpected := new(decimal.Big).SetUint64(0) + x := decimal.WithContext(DecimalContext).SetUint64(10) + y := decimal.WithContext(DecimalContext).SetUint64(5) + qExpected := decimal.WithContext(DecimalContext).SetUint64(2) + rExpected := decimal.WithContext(DecimalContext).SetUint64(0) qReceived, rReceived := DivideBigWithReminder(x, y) if !reflect.DeepEqual(qExpected, qReceived) { t.Errorf("Expected divident <+%v> but received <+%v>", qExpected, qReceived) @@ -311,7 +311,7 @@ func TestDivideBigWithReminder(t *testing.T) { t.Errorf("Expected divident <+%v> but received <+%v>", rExpected, rReceived) } - x = new(decimal.Big).SetUint64(10) + x = decimal.WithContext(DecimalContext).SetUint64(10) y = nil qReceived, rReceived = DivideBigWithReminder(x, y) qExpected = nil diff --git a/utils/eventcharges.go b/utils/eventcharges.go index babc1ece4..63928977c 100644 --- a/utils/eventcharges.go +++ b/utils/eventcharges.go @@ -54,12 +54,8 @@ type ChargeEntry struct { func (ec *EventCharges) Merge(eCs ...*EventCharges) { //ec.SyncIDs(eCs...) // so we can compare properly for _, nEc := range eCs { - if sumAbst := SumDecimalAsBig(ec.Abstracts, nEc.Abstracts); sumAbst != nil { - ec.Abstracts = &Decimal{sumAbst} - } - if sumCrct := SumDecimalAsBig(ec.Concretes, nEc.Concretes); sumCrct != nil { - ec.Concretes = &Decimal{sumCrct} - } + ec.Abstracts = SumDecimal(ec.Abstracts, nEc.Abstracts) + ec.Concretes = SumDecimal(ec.Concretes, nEc.Concretes) ec.appendChargeEntry(nEc.Charges...) for acntID, acntChrg := range nEc.Accounting { ec.Accounting[acntID] = acntChrg diff --git a/utils/libdynamics.go b/utils/libdynamics.go index 47da956eb..f12f321bb 100644 --- a/utils/libdynamics.go +++ b/utils/libdynamics.go @@ -381,10 +381,6 @@ func DynamicDurationPointerOptEqual(v1, v2 []*DynamicDurationPointerOpt) bool { return true } -func CloneDecimalBig(in *decimal.Big) *decimal.Big { - return new(decimal.Big).Copy(in) -} - func StringToDecimalBigDynamicOpts(strOpts []*DynamicStringOpt) (decOpts []*DynamicDecimalBigOpt, err error) { decOpts = make([]*DynamicDecimalBigOpt, len(strOpts)) for index, opt := range strOpts { diff --git a/utils/libdynamics_test.go b/utils/libdynamics_test.go index 7adadf36f..fe55f6432 100644 --- a/utils/libdynamics_test.go +++ b/utils/libdynamics_test.go @@ -149,11 +149,11 @@ func TestCloneDynamicDurationOpt(t *testing.T) { func TestCloneDynamicDecimalBigOpt(t *testing.T) { in := []*DynamicDecimalBigOpt{ { - Value: new(decimal.Big).SetUint64(10), + Value: decimal.WithContext(DecimalContext).SetUint64(10), FilterIDs: []string{"fltr1"}, }, { - Value: new(decimal.Big).SetUint64(2), + Value: decimal.WithContext(DecimalContext).SetUint64(2), FilterIDs: []string{"fltr2"}, }, } @@ -524,12 +524,12 @@ func TestDynamicDecimalBigOptEquals(t *testing.T) { v1 := []*DynamicDecimalBigOpt{ { Tenant: "cgrates.org", - Value: new(decimal.Big).SetUint64(10), + Value: decimal.WithContext(DecimalContext).SetUint64(10), FilterIDs: []string{"fltr1"}, }, { Tenant: "cgrates.org", - Value: new(decimal.Big).SetUint64(2), + Value: decimal.WithContext(DecimalContext).SetUint64(2), FilterIDs: []string{"fltr2"}, }, } @@ -537,12 +537,12 @@ func TestDynamicDecimalBigOptEquals(t *testing.T) { v2 := []*DynamicDecimalBigOpt{ { Tenant: "cgrates.org", - Value: new(decimal.Big).SetUint64(10), + Value: decimal.WithContext(DecimalContext).SetUint64(10), FilterIDs: []string{"fltr1"}, }, { Tenant: "cgrates.org", - Value: new(decimal.Big).SetUint64(2), + Value: decimal.WithContext(DecimalContext).SetUint64(2), FilterIDs: []string{"fltr2"}, }, } @@ -551,7 +551,7 @@ func TestDynamicDecimalBigOptEquals(t *testing.T) { t.Error("Expected both slices to be the same") } - v1[0].Value = new(decimal.Big).SetUint64(16) + v1[0].Value = decimal.WithContext(DecimalContext).SetUint64(16) if DynamicDecimalBigOptEqual(v1, v2) { t.Error("Expected slices to differ") } @@ -571,7 +571,7 @@ func TestDynamicDecimalBigOptEquals(t *testing.T) { //Test if different lengths v1 = append(v1, &DynamicDecimalBigOpt{ - Value: new(decimal.Big).SetUint64(10), + Value: decimal.WithContext(DecimalContext).SetUint64(10), FilterIDs: []string{"fltr1"}, }) if DynamicDecimalBigOptEqual(v1, v2) { @@ -651,7 +651,7 @@ func TestStringToDecimalBigDynamicOpts(t *testing.T) { { FilterIDs: []string{"fld1", "fld2"}, Tenant: "cgrates.org", - Value: new(decimal.Big).SetUint64(200), + Value: decimal.WithContext(DecimalContext).SetUint64(200), }, } @@ -777,7 +777,7 @@ func TestDecimalBigToStringDynamicOpts(t *testing.T) { { FilterIDs: []string{"test_filter", "test_filter2"}, Tenant: "cgrates.org", - Value: new(decimal.Big).SetUint64(300), + Value: decimal.WithContext(DecimalContext).SetUint64(300), }, } diff --git a/utils/librates.go b/utils/librates.go index a273ab74c..bfa579117 100644 --- a/utils/librates.go +++ b/utils/librates.go @@ -408,7 +408,6 @@ func (rIv *RateSInterval) CompressEquals(rIv2 *RateSInterval) (eq bool) { func (rIv *RateSInterval) Cost(rts map[string]*IntervalRate) (cost *decimal.Big) { if rIv.cost == nil { - rIv.cost = new(decimal.Big) for _, incrm := range rIv.Increments { rIv.cost = SumBig(rIv.cost, incrm.Cost(rts)) } @@ -443,7 +442,7 @@ func (rIcr *RateSIncrement) Cost(rts map[string]*IntervalRate) (cost *decimal.Bi if rIcr.CompressFactor != 1 { rIcr.cost = MultiplyBig( rIcr.cost, - new(decimal.Big).SetUint64(uint64(rIcr.CompressFactor))) + decimal.WithContext(DecimalContext).SetUint64(uint64(rIcr.CompressFactor))) } } } diff --git a/utils/librates_test.go b/utils/librates_test.go index 729c04e68..01b17d76c 100644 --- a/utils/librates_test.go +++ b/utils/librates_test.go @@ -1599,7 +1599,7 @@ func TestRateSIncrementCost(t *testing.T) { } cost := rIc.Cost(rts) - exp := new(decimal.Big).SetUint64(15) + exp := decimal.WithContext(DecimalContext).SetUint64(15) if !reflect.DeepEqual(cost, exp) { t.Errorf("Expected %T \n but received \n %T", exp, cost) } @@ -1612,7 +1612,7 @@ func TestRateSIncrementCostNotNil(t *testing.T) { RateID: "RI1", CompressFactor: int64(3), Usage: NewDecimal(int64(30), 0), - cost: new(decimal.Big).SetUint64(15), + cost: decimal.WithContext(DecimalContext).SetUint64(15), } rts := map[string]*IntervalRate{ @@ -1624,7 +1624,7 @@ func TestRateSIncrementCostNotNil(t *testing.T) { } cost := rIc.Cost(rts) - exp := new(decimal.Big).SetUint64(15) + exp := decimal.WithContext(DecimalContext).SetUint64(15) if !reflect.DeepEqual(cost, exp) { t.Errorf("Expected %T \n but received \n %T", exp, cost) } @@ -1672,7 +1672,7 @@ func TestRateSIncrementCostFixedFee(t *testing.T) { } cost := rIc.Cost(rts) - exp := new(decimal.Big).SetUint64(10) + exp := decimal.WithContext(DecimalContext).SetUint64(10) if !reflect.DeepEqual(cost, exp) { t.Errorf("Expected %v \n but received \n %v", exp, cost) } @@ -1698,7 +1698,7 @@ func TestRateSIncrementCostDiffUnitIncrement(t *testing.T) { } cost := rIc.Cost(rts) - exp := new(decimal.Big).SetUint64(3) + exp := decimal.WithContext(DecimalContext).SetUint64(3) if !reflect.DeepEqual(cost, exp) { t.Errorf("Expected %v \n but received \n %v", exp, cost) } @@ -1878,7 +1878,7 @@ func TestRateSIntervalCost(t *testing.T) { } rcv := rIv.Cost(rts) - exp := new(decimal.Big).SetUint64(2) + exp := decimal.WithContext(DecimalContext).SetUint64(2) if !reflect.DeepEqual(rcv, exp) { fmt.Printf("Expected %v \n but received \n %v", exp, rcv) } diff --git a/utils/reflect.go b/utils/reflect.go index 9fa1d3d84..25e0901a2 100644 --- a/utils/reflect.go +++ b/utils/reflect.go @@ -86,7 +86,7 @@ func StringAsBig(itm string) (b *decimal.Big, err error) { } return decimal.New(int64(tm), 0), nil } - z, ok := new(decimal.Big).SetString(itm) + z, ok := decimal.WithContext(DecimalContext).SetString(itm) // verify ok and check if the value was converted successfuly // and the big is a valid number if !ok || z.IsNaN(0) { @@ -110,19 +110,19 @@ func IfaceAsBig(itm interface{}) (b *decimal.Big, err error) { case int64: return decimal.New(it, 0), nil case uint: - return new(decimal.Big).SetUint64(uint64(it)), nil + return decimal.WithContext(DecimalContext).SetUint64(uint64(it)), nil case uint8: - return new(decimal.Big).SetUint64(uint64(it)), nil + return decimal.WithContext(DecimalContext).SetUint64(uint64(it)), nil case uint16: - return new(decimal.Big).SetUint64(uint64(it)), nil + return decimal.WithContext(DecimalContext).SetUint64(uint64(it)), nil case uint32: - return new(decimal.Big).SetUint64(uint64(it)), nil + return decimal.WithContext(DecimalContext).SetUint64(uint64(it)), nil case uint64: - return new(decimal.Big).SetUint64(it), nil + return decimal.WithContext(DecimalContext).SetUint64(it), nil case float32: // automatically hitting here also ints - return new(decimal.Big).SetFloat64(float64(it)), nil + return decimal.WithContext(DecimalContext).SetFloat64(float64(it)), nil case float64: // automatically hitting here also ints - return new(decimal.Big).SetFloat64(it), nil + return decimal.WithContext(DecimalContext).SetFloat64(it), nil case string: return StringAsBig(it) case *Decimal: diff --git a/utils/reflect_test.go b/utils/reflect_test.go index bda45a3fc..5d2e41efc 100644 --- a/utils/reflect_test.go +++ b/utils/reflect_test.go @@ -1231,80 +1231,80 @@ func TestMultiplyInt64Error(t *testing.T) { func TestIfaceAsBig(t *testing.T) { timeDur := time.Duration(1) rcv, _ := IfaceAsBig(timeDur) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(1)) { + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(1)) { t.Errorf("Expected %v but received %v", 1, rcv) } testInt := 2 rcv, _ = IfaceAsBig(testInt) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(2)) { + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(2)) { t.Errorf("Expected %v but received %v", 2, rcv) } testInt8 := int8(3) rcv, _ = IfaceAsBig(testInt8) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(3)) { + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(3)) { t.Errorf("Expected %v but received %v", 3, rcv) } testInt16 := int16(4) rcv, _ = IfaceAsBig(testInt16) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(4)) { + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(4)) { t.Errorf("Expected %v but received %v", 4, rcv) } testInt32 := int32(5) rcv, _ = IfaceAsBig(testInt32) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(5)) { + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(5)) { t.Errorf("Expected %v but received %v", 5, rcv) } testInt64 := int64(6) rcv, _ = IfaceAsBig(testInt64) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(6)) { + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(6)) { t.Errorf("Expected %v but received %v", 6, rcv) } uTestInt := uint(2) rcv, _ = IfaceAsBig(uTestInt) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(2)) { + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(2)) { t.Errorf("Expected %v but received %v", 2, rcv) } uTestInt8 := uint8(3) rcv, _ = IfaceAsBig(uTestInt8) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(3)) { + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(3)) { t.Errorf("Expected %v but received %v", 3, rcv) } uTestInt16 := uint16(4) rcv, _ = IfaceAsBig(uTestInt16) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(4)) { + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(4)) { t.Errorf("Expected %v but received %v", 4, rcv) } uTestInt32 := uint32(5) rcv, _ = IfaceAsBig(uTestInt32) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(5)) { + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(5)) { t.Errorf("Expected %v but received %v", 5, rcv) } uTestInt64 := uint64(6) rcv, _ = IfaceAsBig(uTestInt64) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(6)) { + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(6)) { t.Errorf("Expected %v but received %v", 6, rcv) } testFloat64 := float64(12.2) rcv, _ = IfaceAsBig(testFloat64) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetFloat64(12.2)) { + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetFloat64(12.2)) { t.Errorf("Expected %v but received %v", 12.2, rcv) } testFloat32 := float32(12) rcv, _ = IfaceAsBig(testFloat32) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetFloat64(float64(12))) { - t.Errorf("Expected %v but received %v", new(decimal.Big).SetFloat64(float64(12)), rcv) + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetFloat64(float64(12))) { + t.Errorf("Expected %v but received %v", decimal.WithContext(DecimalContext).SetFloat64(float64(12)), rcv) } timeSuffix := "not_valid_timems" @@ -1319,20 +1319,20 @@ func TestIfaceAsBig(t *testing.T) { if err != nil { t.Error(err) } - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(123)) { - t.Errorf("Expected %v but received %v", new(decimal.Big).SetUint64(123), rcv) + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(123)) { + t.Errorf("Expected %v but received %v", decimal.WithContext(DecimalContext).SetUint64(123), rcv) } - decBig := new(decimal.Big).SetUint64(21) + decBig := decimal.WithContext(DecimalContext).SetUint64(21) rcv, _ = IfaceAsBig(decBig) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(21)) { - t.Errorf("Expected %v but received %v", new(decimal.Big).SetUint64(21), rcv) + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(21)) { + t.Errorf("Expected %v but received %v", decimal.WithContext(DecimalContext).SetUint64(21), rcv) } dec := NewDecimal(10, 0) rcv, _ = IfaceAsBig(dec) - if !reflect.DeepEqual(rcv, new(decimal.Big).SetUint64(10)) { - t.Errorf("Expected %v but received %v", new(decimal.Big).SetUint64(10), rcv) + if !reflect.DeepEqual(rcv, decimal.WithContext(DecimalContext).SetUint64(10)) { + t.Errorf("Expected %v but received %v", decimal.WithContext(DecimalContext).SetUint64(10), rcv) } def := []string{"test"}