mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 13:19:53 +05:00
Config indexed_fields for stats and resources
This commit is contained in:
@@ -423,6 +423,7 @@ const CGRATES_CFG_JSON = `
|
||||
"enabled": false, // starts ResourceLimiter service: <true|false>.
|
||||
"store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur>
|
||||
"thresholds_conns": [], // address where to reach the thresholds service, empty to disable thresholds functionality: <""|*internal|x.y.z.y:1234>
|
||||
"indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
},
|
||||
|
||||
|
||||
@@ -430,6 +431,7 @@ const CGRATES_CFG_JSON = `
|
||||
"enabled": false, // starts Stat service: <true|false>.
|
||||
"store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur>
|
||||
"thresholds_conns": [], // address where to reach the thresholds service, empty to disable thresholds functionality: <""|*internal|x.y.z.y:1234>
|
||||
"indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -692,6 +692,7 @@ func TestDfResourceLimiterSJsonCfg(t *testing.T) {
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Thresholds_conns: &[]*HaPoolJsonCfg{},
|
||||
Store_interval: utils.StringPointer(""),
|
||||
Indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.ResourceSJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
@@ -705,6 +706,7 @@ func TestDfStatServiceJsonCfg(t *testing.T) {
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Store_interval: utils.StringPointer(""),
|
||||
Thresholds_conns: &[]*HaPoolJsonCfg{},
|
||||
Indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.StatSJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -579,6 +579,7 @@ func TestCgrCfgJSONDefaultsResLimCfg(t *testing.T) {
|
||||
Enabled: false,
|
||||
ThresholdSConns: []*HaPoolConfig{},
|
||||
StoreInterval: 0,
|
||||
IndexedFields: []string{},
|
||||
}
|
||||
if !reflect.DeepEqual(cgrCfg.resourceSCfg, eResLiCfg) {
|
||||
t.Errorf("expecting: %s, received: %s", utils.ToJSON(eResLiCfg), utils.ToJSON(cgrCfg.resourceSCfg))
|
||||
@@ -591,6 +592,7 @@ func TestCgrCfgJSONDefaultStatsCfg(t *testing.T) {
|
||||
Enabled: false,
|
||||
StoreInterval: 0,
|
||||
ThresholdSConns: []*HaPoolConfig{},
|
||||
IndexedFields: []string{},
|
||||
}
|
||||
if !reflect.DeepEqual(cgrCfg.statsCfg, eStatsCfg) {
|
||||
t.Errorf("received: %+v, expecting: %+v", cgrCfg.statsCfg, eStatsCfg)
|
||||
|
||||
@@ -391,6 +391,7 @@ type ResourceSJsonCfg struct {
|
||||
Enabled *bool
|
||||
Thresholds_conns *[]*HaPoolJsonCfg
|
||||
Store_interval *string
|
||||
Indexed_fields *[]string
|
||||
}
|
||||
|
||||
// Stat service config section
|
||||
@@ -398,6 +399,7 @@ type StatServJsonCfg struct {
|
||||
Enabled *bool
|
||||
Store_interval *string
|
||||
Thresholds_conns *[]*HaPoolJsonCfg
|
||||
Indexed_fields *[]string
|
||||
}
|
||||
|
||||
// Threshold service config section
|
||||
|
||||
@@ -28,6 +28,7 @@ type ResourceSConfig struct {
|
||||
Enabled bool
|
||||
ThresholdSConns []*HaPoolConfig // Connections towards StatS
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
IndexedFields []string
|
||||
}
|
||||
|
||||
func (rlcfg *ResourceSConfig) loadFromJsonCfg(jsnCfg *ResourceSJsonCfg) (err error) {
|
||||
@@ -49,5 +50,11 @@ func (rlcfg *ResourceSConfig) loadFromJsonCfg(jsnCfg *ResourceSJsonCfg) (err err
|
||||
return
|
||||
}
|
||||
}
|
||||
if jsnCfg.Indexed_fields != nil {
|
||||
rlcfg.IndexedFields = make([]string, len(*jsnCfg.Indexed_fields))
|
||||
for i, fID := range *jsnCfg.Indexed_fields {
|
||||
rlcfg.IndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ type StatSCfg struct {
|
||||
Enabled bool
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
ThresholdSConns []*HaPoolConfig
|
||||
IndexedFields []string
|
||||
}
|
||||
|
||||
func (st *StatSCfg) loadFromJsonCfg(jsnCfg *StatServJsonCfg) (err error) {
|
||||
@@ -49,5 +50,11 @@ func (st *StatSCfg) loadFromJsonCfg(jsnCfg *StatServJsonCfg) (err error) {
|
||||
st.ThresholdSConns[idx].loadFromJsonCfg(jsnHaCfg)
|
||||
}
|
||||
}
|
||||
if jsnCfg.Indexed_fields != nil {
|
||||
st.IndexedFields = make([]string, len(*jsnCfg.Indexed_fields))
|
||||
for i, fID := range *jsnCfg.Indexed_fields {
|
||||
st.IndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user