mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added new config option stringprefix_indexed_fields
This commit is contained in:
committed by
Dan Christian Bogos
parent
0419883d2d
commit
3d88a3ef00
@@ -20,8 +20,9 @@ package config
|
||||
|
||||
// SupplierSCfg is the configuration of supplier service
|
||||
type AttributeSCfg struct {
|
||||
Enabled bool
|
||||
StringIndexedFields []string
|
||||
Enabled bool
|
||||
StringIndexedFields []string
|
||||
StringPrefixIndexedFields []string
|
||||
}
|
||||
|
||||
func (alS *AttributeSCfg) loadFromJsonCfg(jsnCfg *AttributeSJsonCfg) (err error) {
|
||||
@@ -37,5 +38,11 @@ func (alS *AttributeSCfg) loadFromJsonCfg(jsnCfg *AttributeSJsonCfg) (err error)
|
||||
alS.StringIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
if jsnCfg.Stringprefix_indexed_fields != nil {
|
||||
alS.StringPrefixIndexedFields = make([]string, len(*jsnCfg.Stringprefix_indexed_fields))
|
||||
for i, fID := range *jsnCfg.Stringprefix_indexed_fields {
|
||||
alS.StringPrefixIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -428,43 +428,48 @@ const CGRATES_CFG_JSON = `
|
||||
},
|
||||
|
||||
|
||||
"attributes": { // Attribute service
|
||||
"enabled": false, // starts attribute service: <true|false>.
|
||||
"attributes": { // Attribute service
|
||||
"enabled": false, // starts attribute service: <true|false>.
|
||||
"string_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"stringprefix_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
},
|
||||
|
||||
|
||||
"resources": { // Resource service (*new)
|
||||
"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>
|
||||
"resources": { // Resource service (*new)
|
||||
"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>
|
||||
"string_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"stringprefix_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
},
|
||||
|
||||
|
||||
"stats": { // Stat service (*new)
|
||||
"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>
|
||||
"stats": { // Stat service (*new)
|
||||
"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>
|
||||
"string_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"stringprefix_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
},
|
||||
|
||||
|
||||
"thresholds": { // Threshold service (*new)
|
||||
"enabled": false, // starts ThresholdS service: <true|false>.
|
||||
"store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur>
|
||||
"thresholds": { // Threshold service (*new)
|
||||
"enabled": false, // starts ThresholdS service: <true|false>.
|
||||
"store_interval": "", // dump cache regularly to dataDB, 0 - dump at start/shutdown: <""|$dur>
|
||||
"string_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"stringprefix_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
},
|
||||
|
||||
|
||||
"suppliers": { // Supplier service (*new)
|
||||
"enabled": false, // starts SupplierS service: <true|false>.
|
||||
"suppliers": { // Supplier service (*new)
|
||||
"enabled": false, // starts SupplierS service: <true|false>.
|
||||
"string_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"stringprefix_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"rals_conns": [
|
||||
{"address": "*internal"}, // address where to reach the RALs for cost/accounting <*internal>
|
||||
{"address": "*internal"}, // address where to reach the RALs for cost/accounting <*internal>
|
||||
],
|
||||
"resources_conns": [], // address where to reach the Resource service, empty to disable functionality: <""|*internal|x.y.z.y:1234>
|
||||
"stats_conns": [], // address where to reach the Stat service, empty to disable stats functionality: <""|*internal|x.y.z.y:1234>
|
||||
"resources_conns": [], // address where to reach the Resource service, empty to disable functionality: <""|*internal|x.y.z.y:1234>
|
||||
"stats_conns": [], // address where to reach the Stat service, empty to disable stats functionality: <""|*internal|x.y.z.y:1234>
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -716,8 +716,9 @@ func TestDfUserServJsonCfg(t *testing.T) {
|
||||
|
||||
func TestDfAttributeServJsonCfg(t *testing.T) {
|
||||
eCfg := &AttributeSJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Enabled: utils.BoolPointer(false),
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Stringprefix_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.AttributeServJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
@@ -739,10 +740,11 @@ func TestDfFilterSJsonCfg(t *testing.T) {
|
||||
|
||||
func TestDfResourceLimiterSJsonCfg(t *testing.T) {
|
||||
eCfg := &ResourceSJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Thresholds_conns: &[]*HaPoolJsonCfg{},
|
||||
Store_interval: utils.StringPointer(""),
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Thresholds_conns: &[]*HaPoolJsonCfg{},
|
||||
Store_interval: utils.StringPointer(""),
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Stringprefix_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.ResourceSJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
@@ -753,10 +755,11 @@ func TestDfResourceLimiterSJsonCfg(t *testing.T) {
|
||||
|
||||
func TestDfStatServiceJsonCfg(t *testing.T) {
|
||||
eCfg := &StatServJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Store_interval: utils.StringPointer(""),
|
||||
Thresholds_conns: &[]*HaPoolJsonCfg{},
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Store_interval: utils.StringPointer(""),
|
||||
Thresholds_conns: &[]*HaPoolJsonCfg{},
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Stringprefix_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.StatSJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
@@ -767,21 +770,23 @@ func TestDfStatServiceJsonCfg(t *testing.T) {
|
||||
|
||||
func TestDfThresholdSJsonCfg(t *testing.T) {
|
||||
eCfg := &ThresholdSJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Store_interval: utils.StringPointer(""),
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Store_interval: utils.StringPointer(""),
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Stringprefix_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.ThresholdSJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(eCfg, cfg) {
|
||||
t.Errorf("expecting: %+v, received: %+v", eCfg, cfg)
|
||||
t.Errorf("expecting: %+v, received: %+v", utils.ToJSON(eCfg), utils.ToJSON(cfg))
|
||||
}
|
||||
}
|
||||
|
||||
func TestDfSupplierSJsonCfg(t *testing.T) {
|
||||
eCfg := &SupplierSJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Enabled: utils.BoolPointer(false),
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Stringprefix_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Rals_conns: &[]*HaPoolJsonCfg{
|
||||
&HaPoolJsonCfg{
|
||||
Address: utils.StringPointer("*internal"),
|
||||
|
||||
@@ -658,8 +658,9 @@ func TestCgrCfgJSONDefaultFiltersCfg(t *testing.T) {
|
||||
|
||||
func TestCgrCfgJSONDefaultSAttributeSCfg(t *testing.T) {
|
||||
eAliasSCfg := &AttributeSCfg{
|
||||
Enabled: false,
|
||||
StringIndexedFields: []string{},
|
||||
Enabled: false,
|
||||
StringIndexedFields: []string{},
|
||||
StringPrefixIndexedFields: []string{},
|
||||
}
|
||||
if !reflect.DeepEqual(eAliasSCfg, cgrCfg.attributeSCfg) {
|
||||
t.Errorf("received: %+v, expecting: %+v", eAliasSCfg, cgrCfg.attributeSCfg)
|
||||
@@ -668,10 +669,11 @@ func TestCgrCfgJSONDefaultSAttributeSCfg(t *testing.T) {
|
||||
|
||||
func TestCgrCfgJSONDefaultsResLimCfg(t *testing.T) {
|
||||
eResLiCfg := &ResourceSConfig{
|
||||
Enabled: false,
|
||||
ThresholdSConns: []*HaPoolConfig{},
|
||||
StoreInterval: 0,
|
||||
StringIndexedFields: []string{},
|
||||
Enabled: false,
|
||||
ThresholdSConns: []*HaPoolConfig{},
|
||||
StoreInterval: 0,
|
||||
StringIndexedFields: []string{},
|
||||
StringPrefixIndexedFields: []string{},
|
||||
}
|
||||
if !reflect.DeepEqual(cgrCfg.resourceSCfg, eResLiCfg) {
|
||||
t.Errorf("expecting: %s, received: %s", utils.ToJSON(eResLiCfg), utils.ToJSON(cgrCfg.resourceSCfg))
|
||||
@@ -681,10 +683,11 @@ func TestCgrCfgJSONDefaultsResLimCfg(t *testing.T) {
|
||||
|
||||
func TestCgrCfgJSONDefaultStatsCfg(t *testing.T) {
|
||||
eStatsCfg := &StatSCfg{
|
||||
Enabled: false,
|
||||
StoreInterval: 0,
|
||||
ThresholdSConns: []*HaPoolConfig{},
|
||||
StringIndexedFields: []string{},
|
||||
Enabled: false,
|
||||
StoreInterval: 0,
|
||||
ThresholdSConns: []*HaPoolConfig{},
|
||||
StringIndexedFields: []string{},
|
||||
StringPrefixIndexedFields: []string{},
|
||||
}
|
||||
if !reflect.DeepEqual(cgrCfg.statsCfg, eStatsCfg) {
|
||||
t.Errorf("received: %+v, expecting: %+v", cgrCfg.statsCfg, eStatsCfg)
|
||||
@@ -693,9 +696,10 @@ func TestCgrCfgJSONDefaultStatsCfg(t *testing.T) {
|
||||
|
||||
func TestCgrCfgJSONDefaultThresholdSCfg(t *testing.T) {
|
||||
eThresholdSCfg := &ThresholdSCfg{
|
||||
Enabled: false,
|
||||
StoreInterval: 0,
|
||||
StringIndexedFields: []string{},
|
||||
Enabled: false,
|
||||
StoreInterval: 0,
|
||||
StringIndexedFields: []string{},
|
||||
StringPrefixIndexedFields: []string{},
|
||||
}
|
||||
if !reflect.DeepEqual(eThresholdSCfg, cgrCfg.thresholdSCfg) {
|
||||
t.Errorf("received: %+v, expecting: %+v", eThresholdSCfg, cgrCfg.thresholdSCfg)
|
||||
@@ -704,8 +708,10 @@ func TestCgrCfgJSONDefaultThresholdSCfg(t *testing.T) {
|
||||
|
||||
func TestCgrCfgJSONDefaultSupplierSCfg(t *testing.T) {
|
||||
eSupplSCfg := &SupplierSCfg{
|
||||
Enabled: false,
|
||||
StringIndexedFields: []string{},
|
||||
Enabled: false,
|
||||
StringIndexedFields: []string{},
|
||||
StringPrefixIndexedFields: []string{},
|
||||
|
||||
RALsConns: []*HaPoolConfig{
|
||||
&HaPoolConfig{Address: "*internal"},
|
||||
},
|
||||
|
||||
@@ -389,40 +389,45 @@ type UserServJsonCfg struct {
|
||||
|
||||
// Attribute service config section
|
||||
type AttributeSJsonCfg struct {
|
||||
Enabled *bool
|
||||
String_indexed_fields *[]string
|
||||
Enabled *bool
|
||||
String_indexed_fields *[]string
|
||||
Stringprefix_indexed_fields *[]string
|
||||
}
|
||||
|
||||
// ResourceLimiter service config section
|
||||
type ResourceSJsonCfg struct {
|
||||
Enabled *bool
|
||||
Thresholds_conns *[]*HaPoolJsonCfg
|
||||
Store_interval *string
|
||||
String_indexed_fields *[]string
|
||||
Enabled *bool
|
||||
Thresholds_conns *[]*HaPoolJsonCfg
|
||||
Store_interval *string
|
||||
String_indexed_fields *[]string
|
||||
Stringprefix_indexed_fields *[]string
|
||||
}
|
||||
|
||||
// Stat service config section
|
||||
type StatServJsonCfg struct {
|
||||
Enabled *bool
|
||||
Store_interval *string
|
||||
Thresholds_conns *[]*HaPoolJsonCfg
|
||||
String_indexed_fields *[]string
|
||||
Enabled *bool
|
||||
Store_interval *string
|
||||
Thresholds_conns *[]*HaPoolJsonCfg
|
||||
String_indexed_fields *[]string
|
||||
Stringprefix_indexed_fields *[]string
|
||||
}
|
||||
|
||||
// Threshold service config section
|
||||
type ThresholdSJsonCfg struct {
|
||||
Enabled *bool
|
||||
Store_interval *string
|
||||
String_indexed_fields *[]string
|
||||
Enabled *bool
|
||||
Store_interval *string
|
||||
String_indexed_fields *[]string
|
||||
Stringprefix_indexed_fields *[]string
|
||||
}
|
||||
|
||||
// Supplier service config section
|
||||
type SupplierSJsonCfg struct {
|
||||
Enabled *bool
|
||||
String_indexed_fields *[]string
|
||||
Rals_conns *[]*HaPoolJsonCfg
|
||||
Resources_conns *[]*HaPoolJsonCfg
|
||||
Stats_conns *[]*HaPoolJsonCfg
|
||||
Enabled *bool
|
||||
String_indexed_fields *[]string
|
||||
Stringprefix_indexed_fields *[]string
|
||||
Rals_conns *[]*HaPoolJsonCfg
|
||||
Resources_conns *[]*HaPoolJsonCfg
|
||||
Stats_conns *[]*HaPoolJsonCfg
|
||||
}
|
||||
|
||||
// Mailer config section
|
||||
|
||||
@@ -25,10 +25,11 @@ import (
|
||||
)
|
||||
|
||||
type ResourceSConfig struct {
|
||||
Enabled bool
|
||||
ThresholdSConns []*HaPoolConfig // Connections towards StatS
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
StringIndexedFields []string
|
||||
Enabled bool
|
||||
ThresholdSConns []*HaPoolConfig // Connections towards StatS
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
StringIndexedFields []string
|
||||
StringPrefixIndexedFields []string
|
||||
}
|
||||
|
||||
func (rlcfg *ResourceSConfig) loadFromJsonCfg(jsnCfg *ResourceSJsonCfg) (err error) {
|
||||
@@ -56,5 +57,11 @@ func (rlcfg *ResourceSConfig) loadFromJsonCfg(jsnCfg *ResourceSJsonCfg) (err err
|
||||
rlcfg.StringIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
if jsnCfg.Stringprefix_indexed_fields != nil {
|
||||
rlcfg.StringPrefixIndexedFields = make([]string, len(*jsnCfg.Stringprefix_indexed_fields))
|
||||
for i, fID := range *jsnCfg.Stringprefix_indexed_fields {
|
||||
rlcfg.StringPrefixIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -25,10 +25,11 @@ import (
|
||||
)
|
||||
|
||||
type StatSCfg struct {
|
||||
Enabled bool
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
ThresholdSConns []*HaPoolConfig
|
||||
StringIndexedFields []string
|
||||
Enabled bool
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
ThresholdSConns []*HaPoolConfig
|
||||
StringIndexedFields []string
|
||||
StringPrefixIndexedFields []string
|
||||
}
|
||||
|
||||
func (st *StatSCfg) loadFromJsonCfg(jsnCfg *StatServJsonCfg) (err error) {
|
||||
@@ -56,5 +57,11 @@ func (st *StatSCfg) loadFromJsonCfg(jsnCfg *StatServJsonCfg) (err error) {
|
||||
st.StringIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
if jsnCfg.Stringprefix_indexed_fields != nil {
|
||||
st.StringPrefixIndexedFields = make([]string, len(*jsnCfg.Stringprefix_indexed_fields))
|
||||
for i, fID := range *jsnCfg.Stringprefix_indexed_fields {
|
||||
st.StringPrefixIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -20,11 +20,12 @@ package config
|
||||
|
||||
// SupplierSCfg is the configuration of supplier service
|
||||
type SupplierSCfg struct {
|
||||
Enabled bool
|
||||
StringIndexedFields []string
|
||||
RALsConns []*HaPoolConfig
|
||||
ResourceSConns []*HaPoolConfig
|
||||
StatSConns []*HaPoolConfig
|
||||
Enabled bool
|
||||
StringIndexedFields []string
|
||||
StringPrefixIndexedFields []string
|
||||
RALsConns []*HaPoolConfig
|
||||
ResourceSConns []*HaPoolConfig
|
||||
StatSConns []*HaPoolConfig
|
||||
}
|
||||
|
||||
func (spl *SupplierSCfg) loadFromJsonCfg(jsnCfg *SupplierSJsonCfg) (err error) {
|
||||
@@ -40,6 +41,12 @@ func (spl *SupplierSCfg) loadFromJsonCfg(jsnCfg *SupplierSJsonCfg) (err error) {
|
||||
spl.StringIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
if jsnCfg.Stringprefix_indexed_fields != nil {
|
||||
spl.StringPrefixIndexedFields = make([]string, len(*jsnCfg.Stringprefix_indexed_fields))
|
||||
for i, fID := range *jsnCfg.Stringprefix_indexed_fields {
|
||||
spl.StringPrefixIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
if jsnCfg.Rals_conns != nil {
|
||||
spl.RALsConns = make([]*HaPoolConfig, len(*jsnCfg.Rals_conns))
|
||||
for idx, jsnHaCfg := range *jsnCfg.Rals_conns {
|
||||
|
||||
@@ -25,9 +25,10 @@ import (
|
||||
)
|
||||
|
||||
type ThresholdSCfg struct {
|
||||
Enabled bool
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
StringIndexedFields []string
|
||||
Enabled bool
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
StringIndexedFields []string
|
||||
StringPrefixIndexedFields []string
|
||||
}
|
||||
|
||||
func (t *ThresholdSCfg) loadFromJsonCfg(jsnCfg *ThresholdSJsonCfg) (err error) {
|
||||
@@ -48,5 +49,11 @@ func (t *ThresholdSCfg) loadFromJsonCfg(jsnCfg *ThresholdSJsonCfg) (err error) {
|
||||
t.StringIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
if jsnCfg.Stringprefix_indexed_fields != nil {
|
||||
t.StringPrefixIndexedFields = make([]string, len(*jsnCfg.Stringprefix_indexed_fields))
|
||||
for i, fID := range *jsnCfg.Stringprefix_indexed_fields {
|
||||
t.StringPrefixIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -165,6 +165,7 @@
|
||||
"attributes": { // Attribute service
|
||||
"enabled": true, // starts Alias service: <true|false>.
|
||||
"string_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"stringprefix_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -126,9 +126,10 @@
|
||||
},
|
||||
|
||||
|
||||
"attributes": { // Attribute service
|
||||
"enabled": true, // starts Alias service: <true|false>.
|
||||
"attributes": { // Attribute service
|
||||
"enabled": true, // starts Alias service: <true|false>.
|
||||
"string_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"stringprefix_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
},
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user