mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-20 22:58:44 +05:00
ThresholdS indexed_fields option in config
This commit is contained in:
@@ -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
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user