ThresholdS indexed_fields option in config

This commit is contained in:
DanB
2017-10-27 13:47:31 +02:00
parent 38a0217930
commit bf3a36ff91
10 changed files with 49 additions and 29 deletions

View File

@@ -436,7 +436,7 @@ const CGRATES_CFG_JSON = `
"thresholds": {
"enabled": false, // starts ThresholdS service: <true|false>.
"store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur>
"filtered_fields": [], // match filters based on these fields for dynamic filtering, empty to use all
"indexed_fields": [], // query indexes based on these fields for faster processing
},

View File

@@ -715,9 +715,9 @@ func TestDfStatServiceJsonCfg(t *testing.T) {
func TestDfThresholdSJsonCfg(t *testing.T) {
eCfg := &ThresholdSJsonCfg{
Enabled: utils.BoolPointer(false),
Store_interval: utils.StringPointer(""),
Filtered_fields: utils.StringSlicePointer([]string{}),
Enabled: utils.BoolPointer(false),
Store_interval: utils.StringPointer(""),
Indexed_fields: utils.StringSlicePointer([]string{}),
}
if cfg, err := dfCgrJsonCfg.ThresholdSJsonCfg(); err != nil {
t.Error(err)

View File

@@ -601,6 +601,7 @@ func TestCgrCfgJSONDefaultThresholdSCfg(t *testing.T) {
eThresholdSCfg := &ThresholdSCfg{
Enabled: false,
StoreInterval: 0,
IndexedFields: []string{},
}
if !reflect.DeepEqual(eThresholdSCfg, cgrCfg.thresholdSCfg) {
t.Errorf("received: %+v, expecting: %+v", eThresholdSCfg, cgrCfg.statsCfg)

View File

@@ -402,9 +402,9 @@ type StatServJsonCfg struct {
// Threshold service config section
type ThresholdSJsonCfg struct {
Enabled *bool
Store_interval *string
Filtered_fields *[]string
Enabled *bool
Store_interval *string
Indexed_fields *[]string
}
// Mailer config section

View File

@@ -25,9 +25,9 @@ import (
)
type ThresholdSCfg struct {
Enabled bool
StoreInterval time.Duration // Dump regularly from cache into dataDB
FilteredFields []string
Enabled bool
StoreInterval time.Duration // Dump regularly from cache into dataDB
IndexedFields []string
}
func (t *ThresholdSCfg) loadFromJsonCfg(jsnCfg *ThresholdSJsonCfg) (err error) {
@@ -42,5 +42,11 @@ func (t *ThresholdSCfg) loadFromJsonCfg(jsnCfg *ThresholdSJsonCfg) (err error) {
return err
}
}
if jsnCfg.Indexed_fields != nil {
t.IndexedFields = make([]string, len(*jsnCfg.Indexed_fields))
for i, fID := range *jsnCfg.Indexed_fields {
t.IndexedFields[i] = fID
}
}
return nil
}