mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Renamed IndexedFields -> StringIndexedFields
This commit is contained in:
committed by
Dan Christian Bogos
parent
64f32a216e
commit
0419883d2d
@@ -527,7 +527,7 @@ func startAttributeService(internalAttributeSChan chan rpcclient.RpcClientConnec
|
||||
dm *engine.DataManager, server *utils.Server, exitChan chan bool, filterSChan chan *engine.FilterS) {
|
||||
filterS := <-filterSChan
|
||||
filterSChan <- filterS
|
||||
aS, err := engine.NewAttributeService(dm, filterS, cfg.AttributeSCfg().IndexedFields)
|
||||
aS, err := engine.NewAttributeService(dm, filterS, cfg.AttributeSCfg().StringIndexedFields)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<%s> Could not init, error: %s", utils.AttributeS, err.Error()))
|
||||
exitChan <- true
|
||||
@@ -561,7 +561,7 @@ func startResourceService(internalRsChan, internalThresholdSChan chan rpcclient.
|
||||
return
|
||||
}
|
||||
}
|
||||
rS, err := engine.NewResourceService(dm, cfg.ResourceSCfg().StoreInterval, thdSConn, filterS, cfg.ResourceSCfg().IndexedFields)
|
||||
rS, err := engine.NewResourceService(dm, cfg.ResourceSCfg().StoreInterval, thdSConn, filterS, cfg.ResourceSCfg().StringIndexedFields)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<ResourceS> Could not init, error: %s", err.Error()))
|
||||
exitChan <- true
|
||||
@@ -598,7 +598,7 @@ func startStatService(internalStatSChan, internalThresholdSChan chan rpcclient.R
|
||||
return
|
||||
}
|
||||
}
|
||||
sS, err := engine.NewStatService(dm, cfg.StatSCfg().StoreInterval, thdSConn, filterS, cfg.StatSCfg().IndexedFields)
|
||||
sS, err := engine.NewStatService(dm, cfg.StatSCfg().StoreInterval, thdSConn, filterS, cfg.StatSCfg().StringIndexedFields)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<StatS> Could not init, error: %s", err.Error()))
|
||||
exitChan <- true
|
||||
@@ -623,7 +623,7 @@ func startThresholdService(internalThresholdSChan chan rpcclient.RpcClientConnec
|
||||
dm *engine.DataManager, server *utils.Server, exitChan chan bool, filterSChan chan *engine.FilterS) {
|
||||
filterS := <-filterSChan
|
||||
filterSChan <- filterS
|
||||
tS, err := engine.NewThresholdService(dm, cfg.ThresholdSCfg().IndexedFields,
|
||||
tS, err := engine.NewThresholdService(dm, cfg.ThresholdSCfg().StringIndexedFields,
|
||||
cfg.ThresholdSCfg().StoreInterval, filterS)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<ThresholdS> Could not init, error: %s", err.Error()))
|
||||
@@ -676,7 +676,7 @@ func startSupplierService(internalSupplierSChan, internalRsChan, internalStatSCh
|
||||
}
|
||||
}
|
||||
splS, err := engine.NewSupplierService(dm, cfg.DefaultTimezone, filterS,
|
||||
cfg.SupplierSCfg().IndexedFields, resourceSConn, statSConn)
|
||||
cfg.SupplierSCfg().StringIndexedFields, resourceSConn, statSConn)
|
||||
if err != nil {
|
||||
utils.Logger.Crit(fmt.Sprintf("<%s> Could not init, error: %s",
|
||||
utils.SupplierS, err.Error()))
|
||||
|
||||
@@ -20,8 +20,8 @@ package config
|
||||
|
||||
// SupplierSCfg is the configuration of supplier service
|
||||
type AttributeSCfg struct {
|
||||
Enabled bool
|
||||
IndexedFields []string
|
||||
Enabled bool
|
||||
StringIndexedFields []string
|
||||
}
|
||||
|
||||
func (alS *AttributeSCfg) loadFromJsonCfg(jsnCfg *AttributeSJsonCfg) (err error) {
|
||||
@@ -31,10 +31,10 @@ func (alS *AttributeSCfg) loadFromJsonCfg(jsnCfg *AttributeSJsonCfg) (err error)
|
||||
if jsnCfg.Enabled != nil {
|
||||
alS.Enabled = *jsnCfg.Enabled
|
||||
}
|
||||
if jsnCfg.Indexed_fields != nil {
|
||||
alS.IndexedFields = make([]string, len(*jsnCfg.Indexed_fields))
|
||||
for i, fID := range *jsnCfg.Indexed_fields {
|
||||
alS.IndexedFields[i] = fID
|
||||
if jsnCfg.String_indexed_fields != nil {
|
||||
alS.StringIndexedFields = make([]string, len(*jsnCfg.String_indexed_fields))
|
||||
for i, fID := range *jsnCfg.String_indexed_fields {
|
||||
alS.StringIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
@@ -430,7 +430,7 @@ const CGRATES_CFG_JSON = `
|
||||
|
||||
"attributes": { // Attribute service
|
||||
"enabled": false, // starts attribute service: <true|false>.
|
||||
"indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"string_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
},
|
||||
|
||||
|
||||
@@ -438,7 +438,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
|
||||
"string_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
},
|
||||
|
||||
|
||||
@@ -446,20 +446,20 @@ 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
|
||||
"string_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>
|
||||
"indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"string_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
},
|
||||
|
||||
|
||||
"suppliers": { // Supplier service (*new)
|
||||
"enabled": false, // starts SupplierS service: <true|false>.
|
||||
"indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"string_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>
|
||||
],
|
||||
|
||||
@@ -716,8 +716,8 @@ func TestDfUserServJsonCfg(t *testing.T) {
|
||||
|
||||
func TestDfAttributeServJsonCfg(t *testing.T) {
|
||||
eCfg := &AttributeSJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Enabled: utils.BoolPointer(false),
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.AttributeServJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
@@ -739,10 +739,10 @@ func TestDfFilterSJsonCfg(t *testing.T) {
|
||||
|
||||
func TestDfResourceLimiterSJsonCfg(t *testing.T) {
|
||||
eCfg := &ResourceSJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Thresholds_conns: &[]*HaPoolJsonCfg{},
|
||||
Store_interval: utils.StringPointer(""),
|
||||
Indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Thresholds_conns: &[]*HaPoolJsonCfg{},
|
||||
Store_interval: utils.StringPointer(""),
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.ResourceSJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
@@ -753,10 +753,10 @@ func TestDfResourceLimiterSJsonCfg(t *testing.T) {
|
||||
|
||||
func TestDfStatServiceJsonCfg(t *testing.T) {
|
||||
eCfg := &StatServJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Store_interval: utils.StringPointer(""),
|
||||
Thresholds_conns: &[]*HaPoolJsonCfg{},
|
||||
Indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Store_interval: utils.StringPointer(""),
|
||||
Thresholds_conns: &[]*HaPoolJsonCfg{},
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.StatSJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
@@ -767,9 +767,9 @@ func TestDfStatServiceJsonCfg(t *testing.T) {
|
||||
|
||||
func TestDfThresholdSJsonCfg(t *testing.T) {
|
||||
eCfg := &ThresholdSJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Store_interval: utils.StringPointer(""),
|
||||
Indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Store_interval: utils.StringPointer(""),
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
}
|
||||
if cfg, err := dfCgrJsonCfg.ThresholdSJsonCfg(); err != nil {
|
||||
t.Error(err)
|
||||
@@ -780,8 +780,8 @@ func TestDfThresholdSJsonCfg(t *testing.T) {
|
||||
|
||||
func TestDfSupplierSJsonCfg(t *testing.T) {
|
||||
eCfg := &SupplierSJsonCfg{
|
||||
Enabled: utils.BoolPointer(false),
|
||||
Indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Enabled: utils.BoolPointer(false),
|
||||
String_indexed_fields: utils.StringSlicePointer([]string{}),
|
||||
Rals_conns: &[]*HaPoolJsonCfg{
|
||||
&HaPoolJsonCfg{
|
||||
Address: utils.StringPointer("*internal"),
|
||||
|
||||
@@ -658,8 +658,8 @@ func TestCgrCfgJSONDefaultFiltersCfg(t *testing.T) {
|
||||
|
||||
func TestCgrCfgJSONDefaultSAttributeSCfg(t *testing.T) {
|
||||
eAliasSCfg := &AttributeSCfg{
|
||||
Enabled: false,
|
||||
IndexedFields: []string{},
|
||||
Enabled: false,
|
||||
StringIndexedFields: []string{},
|
||||
}
|
||||
if !reflect.DeepEqual(eAliasSCfg, cgrCfg.attributeSCfg) {
|
||||
t.Errorf("received: %+v, expecting: %+v", eAliasSCfg, cgrCfg.attributeSCfg)
|
||||
@@ -668,10 +668,10 @@ func TestCgrCfgJSONDefaultSAttributeSCfg(t *testing.T) {
|
||||
|
||||
func TestCgrCfgJSONDefaultsResLimCfg(t *testing.T) {
|
||||
eResLiCfg := &ResourceSConfig{
|
||||
Enabled: false,
|
||||
ThresholdSConns: []*HaPoolConfig{},
|
||||
StoreInterval: 0,
|
||||
IndexedFields: []string{},
|
||||
Enabled: false,
|
||||
ThresholdSConns: []*HaPoolConfig{},
|
||||
StoreInterval: 0,
|
||||
StringIndexedFields: []string{},
|
||||
}
|
||||
if !reflect.DeepEqual(cgrCfg.resourceSCfg, eResLiCfg) {
|
||||
t.Errorf("expecting: %s, received: %s", utils.ToJSON(eResLiCfg), utils.ToJSON(cgrCfg.resourceSCfg))
|
||||
@@ -681,10 +681,10 @@ func TestCgrCfgJSONDefaultsResLimCfg(t *testing.T) {
|
||||
|
||||
func TestCgrCfgJSONDefaultStatsCfg(t *testing.T) {
|
||||
eStatsCfg := &StatSCfg{
|
||||
Enabled: false,
|
||||
StoreInterval: 0,
|
||||
ThresholdSConns: []*HaPoolConfig{},
|
||||
IndexedFields: []string{},
|
||||
Enabled: false,
|
||||
StoreInterval: 0,
|
||||
ThresholdSConns: []*HaPoolConfig{},
|
||||
StringIndexedFields: []string{},
|
||||
}
|
||||
if !reflect.DeepEqual(cgrCfg.statsCfg, eStatsCfg) {
|
||||
t.Errorf("received: %+v, expecting: %+v", cgrCfg.statsCfg, eStatsCfg)
|
||||
@@ -693,9 +693,9 @@ func TestCgrCfgJSONDefaultStatsCfg(t *testing.T) {
|
||||
|
||||
func TestCgrCfgJSONDefaultThresholdSCfg(t *testing.T) {
|
||||
eThresholdSCfg := &ThresholdSCfg{
|
||||
Enabled: false,
|
||||
StoreInterval: 0,
|
||||
IndexedFields: []string{},
|
||||
Enabled: false,
|
||||
StoreInterval: 0,
|
||||
StringIndexedFields: []string{},
|
||||
}
|
||||
if !reflect.DeepEqual(eThresholdSCfg, cgrCfg.thresholdSCfg) {
|
||||
t.Errorf("received: %+v, expecting: %+v", eThresholdSCfg, cgrCfg.thresholdSCfg)
|
||||
@@ -704,8 +704,8 @@ func TestCgrCfgJSONDefaultThresholdSCfg(t *testing.T) {
|
||||
|
||||
func TestCgrCfgJSONDefaultSupplierSCfg(t *testing.T) {
|
||||
eSupplSCfg := &SupplierSCfg{
|
||||
Enabled: false,
|
||||
IndexedFields: []string{},
|
||||
Enabled: false,
|
||||
StringIndexedFields: []string{},
|
||||
RALsConns: []*HaPoolConfig{
|
||||
&HaPoolConfig{Address: "*internal"},
|
||||
},
|
||||
|
||||
@@ -389,40 +389,40 @@ type UserServJsonCfg struct {
|
||||
|
||||
// Attribute service config section
|
||||
type AttributeSJsonCfg struct {
|
||||
Enabled *bool
|
||||
Indexed_fields *[]string
|
||||
Enabled *bool
|
||||
String_indexed_fields *[]string
|
||||
}
|
||||
|
||||
// ResourceLimiter service config section
|
||||
type ResourceSJsonCfg struct {
|
||||
Enabled *bool
|
||||
Thresholds_conns *[]*HaPoolJsonCfg
|
||||
Store_interval *string
|
||||
Indexed_fields *[]string
|
||||
Enabled *bool
|
||||
Thresholds_conns *[]*HaPoolJsonCfg
|
||||
Store_interval *string
|
||||
String_indexed_fields *[]string
|
||||
}
|
||||
|
||||
// Stat service config section
|
||||
type StatServJsonCfg struct {
|
||||
Enabled *bool
|
||||
Store_interval *string
|
||||
Thresholds_conns *[]*HaPoolJsonCfg
|
||||
Indexed_fields *[]string
|
||||
Enabled *bool
|
||||
Store_interval *string
|
||||
Thresholds_conns *[]*HaPoolJsonCfg
|
||||
String_indexed_fields *[]string
|
||||
}
|
||||
|
||||
// Threshold service config section
|
||||
type ThresholdSJsonCfg struct {
|
||||
Enabled *bool
|
||||
Store_interval *string
|
||||
Indexed_fields *[]string
|
||||
Enabled *bool
|
||||
Store_interval *string
|
||||
String_indexed_fields *[]string
|
||||
}
|
||||
|
||||
// Supplier service config section
|
||||
type SupplierSJsonCfg struct {
|
||||
Enabled *bool
|
||||
Indexed_fields *[]string
|
||||
Rals_conns *[]*HaPoolJsonCfg
|
||||
Resources_conns *[]*HaPoolJsonCfg
|
||||
Stats_conns *[]*HaPoolJsonCfg
|
||||
Enabled *bool
|
||||
String_indexed_fields *[]string
|
||||
Rals_conns *[]*HaPoolJsonCfg
|
||||
Resources_conns *[]*HaPoolJsonCfg
|
||||
Stats_conns *[]*HaPoolJsonCfg
|
||||
}
|
||||
|
||||
// Mailer config section
|
||||
|
||||
@@ -25,10 +25,10 @@ import (
|
||||
)
|
||||
|
||||
type ResourceSConfig struct {
|
||||
Enabled bool
|
||||
ThresholdSConns []*HaPoolConfig // Connections towards StatS
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
IndexedFields []string
|
||||
Enabled bool
|
||||
ThresholdSConns []*HaPoolConfig // Connections towards StatS
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
StringIndexedFields []string
|
||||
}
|
||||
|
||||
func (rlcfg *ResourceSConfig) loadFromJsonCfg(jsnCfg *ResourceSJsonCfg) (err error) {
|
||||
@@ -50,10 +50,10 @@ 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
|
||||
if jsnCfg.String_indexed_fields != nil {
|
||||
rlcfg.StringIndexedFields = make([]string, len(*jsnCfg.String_indexed_fields))
|
||||
for i, fID := range *jsnCfg.String_indexed_fields {
|
||||
rlcfg.StringIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -25,10 +25,10 @@ import (
|
||||
)
|
||||
|
||||
type StatSCfg struct {
|
||||
Enabled bool
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
ThresholdSConns []*HaPoolConfig
|
||||
IndexedFields []string
|
||||
Enabled bool
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
ThresholdSConns []*HaPoolConfig
|
||||
StringIndexedFields []string
|
||||
}
|
||||
|
||||
func (st *StatSCfg) loadFromJsonCfg(jsnCfg *StatServJsonCfg) (err error) {
|
||||
@@ -50,10 +50,10 @@ 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
|
||||
if jsnCfg.String_indexed_fields != nil {
|
||||
st.StringIndexedFields = make([]string, len(*jsnCfg.String_indexed_fields))
|
||||
for i, fID := range *jsnCfg.String_indexed_fields {
|
||||
st.StringIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -20,11 +20,11 @@ package config
|
||||
|
||||
// SupplierSCfg is the configuration of supplier service
|
||||
type SupplierSCfg struct {
|
||||
Enabled bool
|
||||
IndexedFields []string
|
||||
RALsConns []*HaPoolConfig
|
||||
ResourceSConns []*HaPoolConfig
|
||||
StatSConns []*HaPoolConfig
|
||||
Enabled bool
|
||||
StringIndexedFields []string
|
||||
RALsConns []*HaPoolConfig
|
||||
ResourceSConns []*HaPoolConfig
|
||||
StatSConns []*HaPoolConfig
|
||||
}
|
||||
|
||||
func (spl *SupplierSCfg) loadFromJsonCfg(jsnCfg *SupplierSJsonCfg) (err error) {
|
||||
@@ -34,10 +34,10 @@ func (spl *SupplierSCfg) loadFromJsonCfg(jsnCfg *SupplierSJsonCfg) (err error) {
|
||||
if jsnCfg.Enabled != nil {
|
||||
spl.Enabled = *jsnCfg.Enabled
|
||||
}
|
||||
if jsnCfg.Indexed_fields != nil {
|
||||
spl.IndexedFields = make([]string, len(*jsnCfg.Indexed_fields))
|
||||
for i, fID := range *jsnCfg.Indexed_fields {
|
||||
spl.IndexedFields[i] = fID
|
||||
if jsnCfg.String_indexed_fields != nil {
|
||||
spl.StringIndexedFields = make([]string, len(*jsnCfg.String_indexed_fields))
|
||||
for i, fID := range *jsnCfg.String_indexed_fields {
|
||||
spl.StringIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
if jsnCfg.Rals_conns != nil {
|
||||
|
||||
@@ -25,9 +25,9 @@ import (
|
||||
)
|
||||
|
||||
type ThresholdSCfg struct {
|
||||
Enabled bool
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
IndexedFields []string
|
||||
Enabled bool
|
||||
StoreInterval time.Duration // Dump regularly from cache into dataDB
|
||||
StringIndexedFields []string
|
||||
}
|
||||
|
||||
func (t *ThresholdSCfg) loadFromJsonCfg(jsnCfg *ThresholdSJsonCfg) (err error) {
|
||||
@@ -42,10 +42,10 @@ 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
|
||||
if jsnCfg.String_indexed_fields != nil {
|
||||
t.StringIndexedFields = make([]string, len(*jsnCfg.String_indexed_fields))
|
||||
for i, fID := range *jsnCfg.String_indexed_fields {
|
||||
t.StringIndexedFields[i] = fID
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -164,7 +164,7 @@
|
||||
|
||||
"attributes": { // Attribute service
|
||||
"enabled": true, // starts Alias service: <true|false>.
|
||||
"indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"string_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
|
||||
"attributes": { // Attribute service
|
||||
"enabled": true, // starts Alias service: <true|false>.
|
||||
"indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
"string_indexed_fields": [], // query indexes based on these fields for faster processing
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -27,14 +27,14 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func NewAttributeService(dm *DataManager, filterS *FilterS, indexedFields []string) (*AttributeService, error) {
|
||||
return &AttributeService{dm: dm, filterS: filterS, indexedFields: indexedFields}, nil
|
||||
func NewAttributeService(dm *DataManager, filterS *FilterS, stringIndexedFields []string) (*AttributeService, error) {
|
||||
return &AttributeService{dm: dm, filterS: filterS, stringIndexedFields: stringIndexedFields}, nil
|
||||
}
|
||||
|
||||
type AttributeService struct {
|
||||
dm *DataManager
|
||||
filterS *FilterS
|
||||
indexedFields []string
|
||||
dm *DataManager
|
||||
filterS *FilterS
|
||||
stringIndexedFields []string
|
||||
}
|
||||
|
||||
// ListenAndServe will initialize the service
|
||||
@@ -61,7 +61,7 @@ func (alS *AttributeService) matchingAttributeProfilesForEvent(ev *utils.CGREven
|
||||
}
|
||||
attrIdxKey = utils.ConcatenatedKey(ev.Tenant, contextVal)
|
||||
matchingAPs := make(map[string]*AttributeProfile)
|
||||
aPrflIDs, err := matchingItemIDsForEvent(ev.Event, alS.indexedFields,
|
||||
aPrflIDs, err := matchingItemIDsForEvent(ev.Event, alS.stringIndexedFields,
|
||||
alS.dm, utils.AttributeFilterIndexes+attrIdxKey, MetaString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -113,9 +113,9 @@ func testPopulateAttrService(t *testing.T) {
|
||||
dmAtr.SetFilter(filter1)
|
||||
dmAtr.SetFilter(filter2)
|
||||
srv = AttributeService{
|
||||
dm: dmAtr,
|
||||
filterS: &FilterS{dm: dmAtr},
|
||||
indexedFields: []string{"attributeprofile1", "attributeprofile2"},
|
||||
dm: dmAtr,
|
||||
filterS: &FilterS{dm: dmAtr},
|
||||
stringIndexedFields: []string{"attributeprofile1", "attributeprofile2"},
|
||||
}
|
||||
sev = &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
|
||||
@@ -279,7 +279,7 @@ func (rs Resources) allocateResource(ru *ResourceUsage, dryRun bool) (alcMessage
|
||||
|
||||
// Pas the config as a whole so we can ask access concurrently
|
||||
func NewResourceService(dm *DataManager, storeInterval time.Duration,
|
||||
thdS rpcclient.RpcClientConnection, filterS *FilterS, indexedFields []string) (*ResourceService, error) {
|
||||
thdS rpcclient.RpcClientConnection, filterS *FilterS, stringIndexedFields []string) (*ResourceService, error) {
|
||||
if thdS != nil && reflect.ValueOf(thdS).IsNil() {
|
||||
thdS = nil
|
||||
}
|
||||
@@ -293,16 +293,16 @@ func NewResourceService(dm *DataManager, storeInterval time.Duration,
|
||||
|
||||
// ResourceService is the service handling resources
|
||||
type ResourceService struct {
|
||||
dm *DataManager // So we can load the data in cache and index it
|
||||
thdS rpcclient.RpcClientConnection // allows applying filters based on stats
|
||||
filterS *FilterS
|
||||
indexedFields []string // speed up query on indexes
|
||||
lcEventResources map[string][]*utils.TenantID // cache recording resources for events in alocation phase
|
||||
lcERMux sync.RWMutex // protects the lcEventResources
|
||||
storedResources utils.StringMap // keep a record of resources which need saving, map[resID]bool
|
||||
srMux sync.RWMutex // protects storedResources
|
||||
storeInterval time.Duration // interval to dump data on
|
||||
stopBackup chan struct{} // control storing process
|
||||
dm *DataManager // So we can load the data in cache and index it
|
||||
thdS rpcclient.RpcClientConnection // allows applying filters based on stats
|
||||
filterS *FilterS
|
||||
stringIndexedFields []string // speed up query on indexes
|
||||
lcEventResources map[string][]*utils.TenantID // cache recording resources for events in alocation phase
|
||||
lcERMux sync.RWMutex // protects the lcEventResources
|
||||
storedResources utils.StringMap // keep a record of resources which need saving, map[resID]bool
|
||||
srMux sync.RWMutex // protects storedResources
|
||||
storeInterval time.Duration // interval to dump data on
|
||||
stopBackup chan struct{} // control storing process
|
||||
}
|
||||
|
||||
// Called to start the service
|
||||
@@ -434,7 +434,7 @@ func (rS *ResourceService) cachedResourcesForEvent(evUUID string) (rs Resources)
|
||||
// matchingResourcesForEvent returns ordered list of matching resources which are active by the time of the call
|
||||
func (rS *ResourceService) matchingResourcesForEvent(tenant string, ev map[string]interface{}) (rs Resources, err error) {
|
||||
matchingResources := make(map[string]*Resource)
|
||||
rIDs, err := matchingItemIDsForEvent(ev, rS.indexedFields, rS.dm, utils.ResourceFilterIndexes+tenant, MetaString)
|
||||
rIDs, err := matchingItemIDsForEvent(ev, rS.stringIndexedFields, rS.dm, utils.ResourceFilterIndexes+tenant, MetaString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -265,9 +265,9 @@ func TestV1AuthorizeResourceMissingStruct(t *testing.T) {
|
||||
dmresmiss := NewDataManager(data)
|
||||
|
||||
rserv := &ResourceService{
|
||||
dm: dmresmiss,
|
||||
filterS: &FilterS{dm: dmresmiss},
|
||||
indexedFields: []string{}, // speed up query on indexes
|
||||
dm: dmresmiss,
|
||||
filterS: &FilterS{dm: dmresmiss},
|
||||
stringIndexedFields: []string{}, // speed up query on indexes
|
||||
}
|
||||
var reply *string
|
||||
argsMissingTenant := utils.ArgRSv1ResourceUsage{
|
||||
|
||||
@@ -34,30 +34,30 @@ import (
|
||||
|
||||
// NewStatService initializes a StatService
|
||||
func NewStatService(dm *DataManager, storeInterval time.Duration,
|
||||
thdS rpcclient.RpcClientConnection, filterS *FilterS, indexedFields []string) (ss *StatService, err error) {
|
||||
thdS rpcclient.RpcClientConnection, filterS *FilterS, stringIndexedFields []string) (ss *StatService, err error) {
|
||||
if thdS != nil && reflect.ValueOf(thdS).IsNil() { // fix nil value in interface
|
||||
thdS = nil
|
||||
}
|
||||
return &StatService{
|
||||
dm: dm,
|
||||
storeInterval: storeInterval,
|
||||
thdS: thdS,
|
||||
filterS: filterS,
|
||||
indexedFields: indexedFields,
|
||||
storedStatQueues: make(utils.StringMap),
|
||||
stopBackup: make(chan struct{})}, nil
|
||||
dm: dm,
|
||||
storeInterval: storeInterval,
|
||||
thdS: thdS,
|
||||
filterS: filterS,
|
||||
stringIndexedFields: stringIndexedFields,
|
||||
storedStatQueues: make(utils.StringMap),
|
||||
stopBackup: make(chan struct{})}, nil
|
||||
}
|
||||
|
||||
// StatService builds stats for events
|
||||
type StatService struct {
|
||||
dm *DataManager
|
||||
storeInterval time.Duration
|
||||
thdS rpcclient.RpcClientConnection // rpc connection towards ThresholdS
|
||||
filterS *FilterS
|
||||
indexedFields []string
|
||||
stopBackup chan struct{}
|
||||
storedStatQueues utils.StringMap // keep a record of stats which need saving, map[statsTenantID]bool
|
||||
ssqMux sync.RWMutex // protects storedStatQueues
|
||||
dm *DataManager
|
||||
storeInterval time.Duration
|
||||
thdS rpcclient.RpcClientConnection // rpc connection towards ThresholdS
|
||||
filterS *FilterS
|
||||
stringIndexedFields []string
|
||||
stopBackup chan struct{}
|
||||
storedStatQueues utils.StringMap // keep a record of stats which need saving, map[statsTenantID]bool
|
||||
ssqMux sync.RWMutex // protects storedStatQueues
|
||||
}
|
||||
|
||||
// ListenAndServe loops keeps the service alive
|
||||
@@ -141,7 +141,7 @@ func (sS *StatService) StoreStatQueue(sq *StatQueue) (err error) {
|
||||
// matchingStatQueuesForEvent returns ordered list of matching resources which are active by the time of the call
|
||||
func (sS *StatService) matchingStatQueuesForEvent(ev *utils.CGREvent) (sqs StatQueues, err error) {
|
||||
matchingSQs := make(map[string]*StatQueue)
|
||||
sqIDs, err := matchingItemIDsForEvent(ev.Event, sS.indexedFields, sS.dm, utils.StatFilterIndexes+ev.Tenant, MetaString)
|
||||
sqIDs, err := matchingItemIDsForEvent(ev.Event, sS.stringIndexedFields, sS.dm, utils.StatFilterIndexes+ev.Tenant, MetaString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -70,15 +70,15 @@ func (lps SupplierProfiles) Sort() {
|
||||
|
||||
// NewLCRService initializes a LCRService
|
||||
func NewSupplierService(dm *DataManager, timezone string,
|
||||
filterS *FilterS, indexedFields []string, resourceS,
|
||||
filterS *FilterS, stringIndexedFields []string, resourceS,
|
||||
statS rpcclient.RpcClientConnection) (spS *SupplierService, err error) {
|
||||
spS = &SupplierService{
|
||||
dm: dm,
|
||||
timezone: timezone,
|
||||
filterS: filterS,
|
||||
resourceS: resourceS,
|
||||
statS: statS,
|
||||
indexedFields: indexedFields}
|
||||
dm: dm,
|
||||
timezone: timezone,
|
||||
filterS: filterS,
|
||||
resourceS: resourceS,
|
||||
statS: statS,
|
||||
stringIndexedFields: stringIndexedFields}
|
||||
if spS.sorter, err = NewSupplierSortDispatcher(spS); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -87,10 +87,10 @@ func NewSupplierService(dm *DataManager, timezone string,
|
||||
|
||||
// SupplierService is the service computing Supplier queries
|
||||
type SupplierService struct {
|
||||
dm *DataManager
|
||||
timezone string
|
||||
filterS *FilterS
|
||||
indexedFields []string
|
||||
dm *DataManager
|
||||
timezone string
|
||||
filterS *FilterS
|
||||
stringIndexedFields []string
|
||||
resourceS,
|
||||
statS rpcclient.RpcClientConnection
|
||||
sorter SupplierSortDispatcher
|
||||
@@ -114,7 +114,7 @@ func (spS *SupplierService) Shutdown() error {
|
||||
// matchingSupplierProfilesForEvent returns ordered list of matching resources which are active by the time of the call
|
||||
func (spS *SupplierService) matchingSupplierProfilesForEvent(ev *utils.CGREvent) (sPrfls SupplierProfiles, err error) {
|
||||
matchingLPs := make(map[string]*SupplierProfile)
|
||||
sPrflIDs, err := matchingItemIDsForEvent(ev.Event, spS.indexedFields,
|
||||
sPrflIDs, err := matchingItemIDsForEvent(ev.Event, spS.stringIndexedFields,
|
||||
spS.dm, utils.SupplierFilterIndexes+ev.Tenant, MetaString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -187,10 +187,10 @@ func TestSuppliersPopulateSupplierService(t *testing.T) {
|
||||
ssd := make(map[string]SuppliersSorter)
|
||||
ssd[utils.MetaWeight] = NewWeightSorter()
|
||||
splserv = SupplierService{
|
||||
dm: dmspl,
|
||||
filterS: &FilterS{dm: dmspl},
|
||||
indexedFields: []string{"supplierprofile1", "supplierprofile2"},
|
||||
sorter: ssd,
|
||||
dm: dmspl,
|
||||
filterS: &FilterS{dm: dmspl},
|
||||
stringIndexedFields: []string{"supplierprofile1", "supplierprofile2"},
|
||||
sorter: ssd,
|
||||
}
|
||||
ssd[utils.MetaLeastCost] = NewLeastCostSorter(&splserv)
|
||||
argPagEv = &ArgsGetSuppliers{
|
||||
|
||||
@@ -112,25 +112,25 @@ func (ts Thresholds) Sort() {
|
||||
sort.Slice(ts, func(i, j int) bool { return ts[i].tPrfl.Weight > ts[j].tPrfl.Weight })
|
||||
}
|
||||
|
||||
func NewThresholdService(dm *DataManager, indexedFields []string, storeInterval time.Duration,
|
||||
func NewThresholdService(dm *DataManager, stringIndexedFields []string, storeInterval time.Duration,
|
||||
filterS *FilterS) (tS *ThresholdService, err error) {
|
||||
return &ThresholdService{dm: dm,
|
||||
indexedFields: indexedFields,
|
||||
storeInterval: storeInterval,
|
||||
filterS: filterS,
|
||||
stopBackup: make(chan struct{}),
|
||||
storedTdIDs: make(utils.StringMap)}, nil
|
||||
stringIndexedFields: stringIndexedFields,
|
||||
storeInterval: storeInterval,
|
||||
filterS: filterS,
|
||||
stopBackup: make(chan struct{}),
|
||||
storedTdIDs: make(utils.StringMap)}, nil
|
||||
}
|
||||
|
||||
// ThresholdService manages Threshold execution and storing them to dataDB
|
||||
type ThresholdService struct {
|
||||
dm *DataManager
|
||||
indexedFields []string // fields considered when searching for matching thresholds
|
||||
storeInterval time.Duration
|
||||
filterS *FilterS
|
||||
stopBackup chan struct{}
|
||||
storedTdIDs utils.StringMap // keep a record of stats which need saving, map[statsTenantID]bool
|
||||
stMux sync.RWMutex // protects storedTdIDs
|
||||
dm *DataManager
|
||||
stringIndexedFields []string // fields considered when searching for matching thresholds
|
||||
storeInterval time.Duration
|
||||
filterS *FilterS
|
||||
stopBackup chan struct{}
|
||||
storedTdIDs utils.StringMap // keep a record of stats which need saving, map[statsTenantID]bool
|
||||
stMux sync.RWMutex // protects storedTdIDs
|
||||
}
|
||||
|
||||
// Called to start the service
|
||||
@@ -219,7 +219,7 @@ func (tS *ThresholdService) matchingThresholdsForEvent(args *ArgsProcessEvent) (
|
||||
if len(args.ThresholdIDs) != 0 {
|
||||
tIDs = args.ThresholdIDs
|
||||
} else {
|
||||
tIDsMap, err := matchingItemIDsForEvent(args.Event, tS.indexedFields, tS.dm, utils.ThresholdFilterIndexes+args.Tenant, MetaString)
|
||||
tIDsMap, err := matchingItemIDsForEvent(args.Event, tS.stringIndexedFields, tS.dm, utils.ThresholdFilterIndexes+args.Tenant, MetaString)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user