mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 05:09:54 +05:00
Added verbosity in RateS config
This commit is contained in:
committed by
Dan Christian Bogos
parent
f0975a0b1a
commit
31b10532b9
@@ -969,6 +969,7 @@ const CGRATES_CFG_JSON = `
|
||||
"rate_prefix_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"rate_suffix_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"rate_nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level)
|
||||
"verbosity": 1000, // number of increment iterations allowed
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -2053,6 +2053,7 @@ func TestDfRateSJsonCfg(t *testing.T) {
|
||||
Rate_prefix_indexed_fields: &[]string{},
|
||||
Rate_suffix_indexed_fields: &[]string{},
|
||||
Rate_nested_fields: utils.BoolPointer(false),
|
||||
Verbosity: utils.IntPointer(1000),
|
||||
}
|
||||
dfCgrJSONCfg, err := NewCgrJsonCfgFromBytes([]byte(CGRATES_CFG_JSON))
|
||||
if err != nil {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -638,6 +638,7 @@ type RateSJsonCfg struct {
|
||||
Rate_prefix_indexed_fields *[]string
|
||||
Rate_suffix_indexed_fields *[]string
|
||||
Rate_nested_fields *bool // applies when indexed fields is not defined
|
||||
Verbosity *int
|
||||
}
|
||||
|
||||
// SIPAgentJsonCfg
|
||||
|
||||
@@ -35,6 +35,7 @@ type RateSCfg struct {
|
||||
RatePrefixIndexedFields *[]string
|
||||
RateSuffixIndexedFields *[]string
|
||||
RateNestedFields bool
|
||||
Verbosity int
|
||||
}
|
||||
|
||||
func (rCfg *RateSCfg) loadFromJSONCfg(jsnCfg *RateSJsonCfg) (err error) {
|
||||
@@ -99,6 +100,9 @@ func (rCfg *RateSCfg) loadFromJSONCfg(jsnCfg *RateSJsonCfg) (err error) {
|
||||
if jsnCfg.Rate_nested_fields != nil {
|
||||
rCfg.RateNestedFields = *jsnCfg.Rate_nested_fields
|
||||
}
|
||||
if jsnCfg.Verbosity != nil {
|
||||
rCfg.Verbosity = *jsnCfg.Verbosity
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -110,6 +114,7 @@ func (rCfg *RateSCfg) AsMapInterface() (initialMP map[string]interface{}) {
|
||||
utils.NestedFieldsCfg: rCfg.NestedFields,
|
||||
utils.RateIndexedSelectsCfg: rCfg.RateIndexedSelects,
|
||||
utils.RateNestedFieldsCfg: rCfg.RateNestedFields,
|
||||
utils.Verbosity: rCfg.Verbosity,
|
||||
}
|
||||
if rCfg.StringIndexedFields != nil {
|
||||
stringIndexedFields := make([]string, len(*rCfg.StringIndexedFields))
|
||||
@@ -164,6 +169,7 @@ func (rCfg RateSCfg) Clone() (cln *RateSCfg) {
|
||||
NestedFields: rCfg.NestedFields,
|
||||
RateIndexedSelects: rCfg.RateIndexedSelects,
|
||||
RateNestedFields: rCfg.RateNestedFields,
|
||||
Verbosity: rCfg.Verbosity,
|
||||
}
|
||||
if rCfg.StringIndexedFields != nil {
|
||||
idx := make([]string, len(*rCfg.StringIndexedFields))
|
||||
|
||||
@@ -38,6 +38,7 @@ func TestRateSConfigloadFromJsonCfg(t *testing.T) {
|
||||
Rate_prefix_indexed_fields: &[]string{"*req.index1"},
|
||||
Rate_suffix_indexed_fields: &[]string{"*req.index1"},
|
||||
Rate_nested_fields: utils.BoolPointer(true),
|
||||
Verbosity: utils.IntPointer(20),
|
||||
}
|
||||
expected := &RateSCfg{
|
||||
Enabled: true,
|
||||
@@ -51,6 +52,7 @@ func TestRateSConfigloadFromJsonCfg(t *testing.T) {
|
||||
RatePrefixIndexedFields: &[]string{"*req.index1"},
|
||||
RateSuffixIndexedFields: &[]string{"*req.index1"},
|
||||
RateNestedFields: true,
|
||||
Verbosity: 20,
|
||||
}
|
||||
jsonCfg := NewDefaultCGRConfig()
|
||||
if err = jsonCfg.rateSCfg.loadFromJSONCfg(cfgJSON); err != nil {
|
||||
@@ -74,6 +76,7 @@ func TestRatesCfgAsMapInterface(t *testing.T) {
|
||||
utils.RatePrefixIndexedFieldsCfg: []string{},
|
||||
utils.RateSuffixIndexedFieldsCfg: []string{},
|
||||
utils.RateNestedFieldsCfg: false,
|
||||
utils.Verbosity: 1000,
|
||||
}
|
||||
if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
|
||||
t.Error(err)
|
||||
@@ -110,6 +113,7 @@ func TestRatesCfgAsMapInterface1(t *testing.T) {
|
||||
utils.RatePrefixIndexedFieldsCfg: []string{"*req.index1", "*req.index2"},
|
||||
utils.RateSuffixIndexedFieldsCfg: []string{"*req.index1", "*req.index2", "*req.index3"},
|
||||
utils.RateNestedFieldsCfg: true,
|
||||
utils.Verbosity: 1000,
|
||||
}
|
||||
if cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSONStr); err != nil {
|
||||
t.Error(err)
|
||||
@@ -131,6 +135,7 @@ func TestRateSCfgClone(t *testing.T) {
|
||||
RatePrefixIndexedFields: &[]string{"*req.index1"},
|
||||
RateSuffixIndexedFields: &[]string{"*req.index1"},
|
||||
RateNestedFields: true,
|
||||
Verbosity: 20,
|
||||
}
|
||||
rcv := sa.Clone()
|
||||
if !reflect.DeepEqual(sa, rcv) {
|
||||
|
||||
@@ -2255,6 +2255,7 @@ const (
|
||||
RateStringIndexedFieldsCfg = "rate_string_indexed_fields"
|
||||
RatePrefixIndexedFieldsCfg = "rate_prefix_indexed_fields"
|
||||
RateSuffixIndexedFieldsCfg = "rate_suffix_indexed_fields"
|
||||
Verbosity = "verbosity"
|
||||
|
||||
// AnalyzerSCfg
|
||||
CleanupIntervalCfg = "cleanup_interval"
|
||||
|
||||
Reference in New Issue
Block a user