diff --git a/apis/config_it_test.go b/apis/config_it_test.go index 0e9fc404b..36767cf29 100644 --- a/apis/config_it_test.go +++ b/apis/config_it_test.go @@ -153,7 +153,7 @@ func testCfgGetConfig(t *testing.T) { "resources_conns": []string{"*localhost"}, "stats_conns": []string{"*localhost"}, "suffix_indexed_fields": []string{}, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(1), }, }, @@ -189,7 +189,7 @@ func testCfgSetGetConfig(t *testing.T) { "resources_conns": []string{"*internal"}, "stats_conns": []string{"*internal"}, "suffix_indexed_fields": []string{}, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: 2, }, }, @@ -212,7 +212,7 @@ func testCfgSetGetConfig(t *testing.T) { "resources_conns": []string{"*internal"}, "stats_conns": []string{"*internal"}, "suffix_indexed_fields": []string{}, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(2), }, }, @@ -302,7 +302,7 @@ func testCfgSetJSONGetJSONConfig(t *testing.T) { &config.SetConfigFromJSONArgs{ APIOpts: nil, Tenant: "", - Config: "{\"attributes\":{\"accounts_conns\":[\"*internal\"],\"enabled\":true,\"indexed_selects\":false,\"nested_fields\":false,\"prefix_indexed_fields\":[],\"resources_conns\":[\"*internal\"],\"stats_conns\":[\"*localhost\"],\"suffix_indexed_fields\":[],\"default_opts\":{\"*processRuns\":2}}}", + Config: "{\"attributes\":{\"accounts_conns\":[\"*internal\"],\"enabled\":true,\"indexed_selects\":false,\"nested_fields\":false,\"prefix_indexed_fields\":[],\"resources_conns\":[\"*internal\"],\"stats_conns\":[\"*localhost\"],\"suffix_indexed_fields\":[],\"opts\":{\"*processRuns\":2}}}", DryRun: false, }, &reply); err != nil { @@ -311,7 +311,7 @@ func testCfgSetJSONGetJSONConfig(t *testing.T) { if !reflect.DeepEqual(`"OK"`, utils.ToJSON(reply)) { t.Errorf("\nExpected <%+v>, \nReceived <%+v>", "OK", utils.ToJSON(reply)) } - expectedGet := "{\"attributes\":{\"accounts_conns\":[\"*internal\"],\"default_opts\":{\"*processRuns\":2},\"enabled\":true,\"indexed_selects\":false,\"nested_fields\":false,\"prefix_indexed_fields\":[],\"resources_conns\":[\"*internal\"],\"stats_conns\":[\"*localhost\"],\"suffix_indexed_fields\":[]}}" + expectedGet := "{\"attributes\":{\"accounts_conns\":[\"*internal\"],\"opts\":{\"*processRuns\":2},\"enabled\":true,\"indexed_selects\":false,\"nested_fields\":false,\"prefix_indexed_fields\":[],\"resources_conns\":[\"*internal\"],\"stats_conns\":[\"*localhost\"],\"suffix_indexed_fields\":[]}}" var replyGet string if err := cfgRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{ @@ -430,7 +430,7 @@ func testCfgGetConfigStore(t *testing.T) { Prefix_indexed_fields: nil, Suffix_indexed_fields: nil, Nested_fields: nil, - Default_opts: make(map[string]interface{}), + Opts: make(map[string]interface{}), } if !reflect.DeepEqual(attr, expected) { t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.ToJSON(expected), utils.ToJSON(attr)) @@ -454,7 +454,7 @@ func testCfgSetGetConfigStore(t *testing.T) { "resources_conns": []string{"*internal"}, "stats_conns": []string{"*internal"}, "suffix_indexed_fields": []string{}, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: 2, }, }, @@ -477,7 +477,7 @@ func testCfgSetGetConfigStore(t *testing.T) { "resources_conns": []string{"*internal"}, "stats_conns": []string{"*internal"}, "suffix_indexed_fields": []string{}, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: 2, }, }, @@ -512,7 +512,7 @@ func testCfgGetConfigStoreAgain(t *testing.T) { Prefix_indexed_fields: nil, Suffix_indexed_fields: nil, Nested_fields: nil, - Default_opts: map[string]interface{}{ + Opts: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(2), }, } @@ -532,7 +532,7 @@ func testCfgMdfSectConfigStore(t *testing.T) { Prefix_indexed_fields: nil, Suffix_indexed_fields: nil, Nested_fields: nil, - Default_opts: map[string]interface{}{ + Opts: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(2), }, } @@ -571,7 +571,7 @@ func testCfgGetAfterReloadStore(t *testing.T) { "resources_conns": []string{"*internal"}, "stats_conns": []string{"*internal"}, "suffix_indexed_fields": []string{}, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: 2, }, }, diff --git a/apis/config_test.go b/apis/config_test.go index 533290079..398c9591c 100644 --- a/apis/config_test.go +++ b/apis/config_test.go @@ -73,7 +73,7 @@ func TestConfigSetGetConfig(t *testing.T) { "resources_conns": []string{"*localhost"}, "stats_conns": []string{"*localhost"}, "suffix_indexed_fields": []string{}, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(1), }, utils.ProfileRunsCfg: 0, @@ -109,7 +109,7 @@ func TestConfigSetGetReloadConfig(t *testing.T) { "resources_conns": []string{"*internal"}, "stats_conns": []string{"*internal"}, "suffix_indexed_fields": []string{}, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: 2, }, }, @@ -140,7 +140,7 @@ func TestConfigSetGetReloadConfig(t *testing.T) { "resources_conns": []string{"*localhost"}, "stats_conns": []string{"*localhost"}, "suffix_indexed_fields": []string{}, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(1), }, utils.ProfileRunsCfg: 0, @@ -181,7 +181,7 @@ func TestConfigSetGetReloadConfig(t *testing.T) { "resources_conns": []string{"*localhost"}, "stats_conns": []string{"*localhost"}, "suffix_indexed_fields": []string{}, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(1), }, utils.ProfileRunsCfg: 0, @@ -207,7 +207,7 @@ func TestConfigGetSetConfigFromJSONErr(t *testing.T) { args := &config.SetConfigFromJSONArgs{ APIOpts: nil, Tenant: utils.CGRateSorg, - Config: "{\"attributes\":{\"accounts_conns\":[\"*localhost\"],\"default_opts\":{\"*processRuns\":2},\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":false,\"prefix_indexed_fields\":[],\"resources_conns\":[\"*localhost\"],\"stats_conns\":[\"*localhost\"],\"suffix_indexed_fields\":[]}}", + Config: "{\"attributes\":{\"accounts_conns\":[\"*localhost\"],\"opts\":{\"*processRuns\":2},\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":false,\"prefix_indexed_fields\":[],\"resources_conns\":[\"*localhost\"],\"stats_conns\":[\"*localhost\"],\"suffix_indexed_fields\":[]}}", DryRun: true, } var reply string @@ -227,7 +227,11 @@ func TestConfigGetSetConfigFromJSONErr(t *testing.T) { } var replyGet string errGet := rlcCfg.GetConfigAsJSON(context.Background(), argsGet, &replyGet) +<<<<<<< HEAD expectedGet := `{"attributes":{"accounts_conns":["*localhost"],"default_opts":{"*processRuns":1},"enabled":true,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"profile_runs":0,"resources_conns":["*localhost"],"stats_conns":["*localhost"],"suffix_indexed_fields":[]}}` +======= + expectedGet := "{\"attributes\":{\"accounts_conns\":[\"*localhost\"],\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":false,\"opts\":{\"*processRuns\":1},\"prefix_indexed_fields\":[],\"resources_conns\":[\"*localhost\"],\"stats_conns\":[\"*localhost\"],\"suffix_indexed_fields\":[]}}" +>>>>>>> 3df2de22e (Rename default_opts to opts) if err != nil { t.Errorf("Expected <%+v>, \nReceived <%+v>", nil, errGet) } diff --git a/config/attributescfg.go b/config/attributescfg.go index 6d1b27efe..fcc384fae 100644 --- a/config/attributescfg.go +++ b/config/attributescfg.go @@ -69,8 +69,8 @@ func (alS *AttributeSCfg) loadFromJSONCfg(jsnCfg *AttributeSJsonCfg) (err error) if jsnCfg.Nested_fields != nil { alS.NestedFields = *jsnCfg.Nested_fields } - if jsnCfg.Default_opts != nil { - alS.DefaultOpts = jsnCfg.Default_opts + if jsnCfg.Opts != nil { + alS.DefaultOpts = jsnCfg.Opts } return } @@ -82,7 +82,7 @@ func (alS *AttributeSCfg) AsMapInterface() (initialMP map[string]interface{}) { utils.IndexedSelectsCfg: alS.IndexedSelects, utils.ProfileRunsCfg: alS.ProfileRuns, utils.NestedFieldsCfg: alS.NestedFields, - utils.DefaultOptsCfg: alS.DefaultOpts, + utils.OptsCfg: alS.DefaultOpts, } if alS.StringIndexedFields != nil { initialMP[utils.StringIndexedFieldsCfg] = utils.CloneStringSlice(*alS.StringIndexedFields) @@ -148,8 +148,12 @@ type AttributeSJsonCfg struct { Prefix_indexed_fields *[]string Suffix_indexed_fields *[]string Nested_fields *bool // applies when indexed fields is not defined +<<<<<<< HEAD Default_opts map[string]interface{} Profile_runs *int +======= + Opts map[string]interface{} +>>>>>>> 3df2de22e (Rename default_opts to opts) } func diffAttributeSJsonCfg(d *AttributeSJsonCfg, v1, v2 *AttributeSCfg) *AttributeSJsonCfg { @@ -177,7 +181,7 @@ func diffAttributeSJsonCfg(d *AttributeSJsonCfg, v1, v2 *AttributeSCfg) *Attribu if v1.NestedFields != v2.NestedFields { d.Nested_fields = utils.BoolPointer(v2.NestedFields) } - d.Default_opts = diffMap(d.Default_opts, v1.DefaultOpts, v2.DefaultOpts) + d.Opts = diffMap(d.Opts, v1.DefaultOpts, v2.DefaultOpts) return d } diff --git a/config/attributescfg_test.go b/config/attributescfg_test.go index 534b40ab5..1b8932f3a 100644 --- a/config/attributescfg_test.go +++ b/config/attributescfg_test.go @@ -67,7 +67,7 @@ func TestAttributeSCfgAsMapInterface(t *testing.T) { "accounts_conns": ["*internal"], "prefix_indexed_fields": ["*req.index1","*req.index2"], "string_indexed_fields": ["*req.index1"], - "default_opts": { + "opts": { "*processRuns": 3, }, }, @@ -83,7 +83,7 @@ func TestAttributeSCfgAsMapInterface(t *testing.T) { utils.IndexedSelectsCfg: true, utils.NestedFieldsCfg: false, utils.SuffixIndexedFieldsCfg: []string{}, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(3), }, } @@ -100,7 +100,7 @@ func TestAttributeSCfgAsMapInterface2(t *testing.T) { "suffix_indexed_fields": ["*req.index1","*req.index2"], "nested_fields": true, "enabled": true, - "default_opts": { + "opts": { "*processRuns": 7, }, }, @@ -114,7 +114,7 @@ func TestAttributeSCfgAsMapInterface2(t *testing.T) { utils.PrefixIndexedFieldsCfg: []string{}, utils.SuffixIndexedFieldsCfg: []string{"*req.index1", "*req.index2"}, utils.NestedFieldsCfg: true, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(7), }, utils.ProfileRunsCfg: 0, @@ -141,7 +141,7 @@ func TestAttributeSCfgAsMapInterface3(t *testing.T) { utils.PrefixIndexedFieldsCfg: []string{}, utils.SuffixIndexedFieldsCfg: []string{}, utils.NestedFieldsCfg: false, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(1), }, utils.ProfileRunsCfg: 0, @@ -232,7 +232,7 @@ func TestDiffAttributeSJsonCfg(t *testing.T) { Prefix_indexed_fields: nil, Suffix_indexed_fields: nil, Nested_fields: utils.BoolPointer(false), - Default_opts: map[string]interface{}{}, + Opts: map[string]interface{}{}, } rcv := diffAttributeSJsonCfg(d, v1, v2) @@ -242,7 +242,7 @@ func TestDiffAttributeSJsonCfg(t *testing.T) { v2_2 := v1 expected2 := &AttributeSJsonCfg{ - Default_opts: map[string]interface{}{}, + Opts: map[string]interface{}{}, } rcv = diffAttributeSJsonCfg(d, v1, v2_2) if !reflect.DeepEqual(rcv, expected2) { diff --git a/config/config.go b/config/config.go index bb3ad8c11..1c083fe97 100644 --- a/config/config.go +++ b/config/config.go @@ -147,7 +147,7 @@ func newCGRConfig(config []byte) (cfg *CGRConfig, err error) { cfg.statsCfg = new(StatSCfg) cfg.thresholdSCfg = new(ThresholdSCfg) cfg.routeSCfg = new(RouteSCfg) - cfg.RouteSCfg().DefaultOpts = &RoutesOpts{} + cfg.RouteSCfg().Opts = &RoutesOpts{} cfg.sureTaxCfg = new(SureTaxCfg) cfg.dispatcherSCfg = new(DispatcherSCfg) cfg.registrarCCfg = new(RegistrarCCfgs) diff --git a/config/config_defaults.go b/config/config_defaults.go index 5420872b4..34477931f 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -667,7 +667,7 @@ const CGRATES_CFG_JSON = ` "prefix_indexed_fields": [], // query indexes based on these fields for faster processing "suffix_indexed_fields": [], // query indexes based on these fields for faster processing "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level) - "default_opts":{ // + "opts":{ // "*processRuns": 1, // number of run loops when processing event }, "profile_runs": 0, // number of run a profile will process the event @@ -735,7 +735,7 @@ const CGRATES_CFG_JSON = ` "rates_conns": [], // connections to RateS "accounts_conns": [], // connections to AccountS "default_ratio":1, // default ratio used in case of *load strategy - "default_opts":{ + "opts":{ "*context": "*routes", "*profileCount": 1, "*ignoreErrors": false, diff --git a/config/config_it_test.go b/config/config_it_test.go index 77c42771a..7073a48c9 100644 --- a/config/config_it_test.go +++ b/config/config_it_test.go @@ -356,7 +356,7 @@ func testCGRConfigReloadSupplierS(t *testing.T) { AccountSConns: []string{}, IndexedSelects: true, DefaultRatio: 1, - DefaultOpts: &RoutesOpts{ + Opts: &RoutesOpts{ Context: utils.MetaRoutes, ProfileCount: 1, IgnoreErrors: false, diff --git a/config/config_json_test.go b/config/config_json_test.go index 651edb84b..2a0b1c908 100644 --- a/config/config_json_test.go +++ b/config/config_json_test.go @@ -753,7 +753,7 @@ func TestDfAttributeServJsonCfg(t *testing.T) { Prefix_indexed_fields: &[]string{}, Suffix_indexed_fields: &[]string{}, Nested_fields: utils.BoolPointer(false), - Default_opts: map[string]interface{}{ + Opts: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(1), }, Profile_runs: utils.IntPointer(0), @@ -890,7 +890,7 @@ func TestDfRouteSJsonCfg(t *testing.T) { Accounts_conns: &[]string{}, Default_ratio: utils.IntPointer(1), Nested_fields: utils.BoolPointer(false), - Default_opts: &RoutesOptsJson{ + Opts: &RoutesOptsJson{ Context: utils.StringPointer(utils.MetaRoutes), ProfileCount: utils.Float64Pointer(float64(1)), IgnoreErrors: utils.BoolPointer(false), diff --git a/config/config_test.go b/config/config_test.go index 8a2962675..19505d827 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -740,7 +740,7 @@ func TestCgrCfgJSONDefaultRouteSCfg(t *testing.T) { RateSConns: []string{}, AccountSConns: []string{}, DefaultRatio: 1, - DefaultOpts: &RoutesOpts{ + Opts: &RoutesOpts{ Context: utils.MetaRoutes, ProfileCount: float64(1), IgnoreErrors: false, @@ -1956,7 +1956,7 @@ func TestRouteSConfig(t *testing.T) { AccountSConns: []string{}, DefaultRatio: 1, NestedFields: false, - DefaultOpts: &RoutesOpts{ + Opts: &RoutesOpts{ Context: utils.MetaRoutes, ProfileCount: float64(1), IgnoreErrors: false, @@ -4156,7 +4156,7 @@ func TestV1GetConfigAttribute(t *testing.T) { utils.PrefixIndexedFieldsCfg: []string{}, utils.SuffixIndexedFieldsCfg: []string{}, utils.NestedFieldsCfg: false, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(1), }, utils.ProfileRunsCfg: 0, @@ -4293,7 +4293,7 @@ func TestV1GetConfigRoutes(t *testing.T) { utils.RateSConnsCfg: []string{}, utils.AccountSConnsCfg: []string{}, utils.DefaultRatioCfg: 1, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsContext: utils.MetaRoutes, utils.MetaProfileCountCfg: float64(1), utils.MetaIgnoreErrorsCfg: false, @@ -5079,7 +5079,7 @@ func TestV1GetConfigAsJSONThresholdS(t *testing.T) { func TestV1GetConfigAsJSONRouteS(t *testing.T) { var reply string - expected := `{"routes":{"accounts_conns":[],"attributes_conns":[],"default_opts":{"*context":"*routes","*ignoreErrors":false,"*maxCost":"","*profileCount":1},"default_ratio":1,"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"rates_conns":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]}}` + expected := `{"routes":{"accounts_conns":[],"attributes_conns":[],"default_ratio":1,"enabled":false,"indexed_selects":true,"nested_fields":false,"opts":{"*context":"*routes","*ignoreErrors":false,"*maxCost":"","*profileCount":1},"prefix_indexed_fields":[],"rates_conns":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]}}` cgrCfg := NewDefaultCGRConfig() if err := cgrCfg.V1GetConfigAsJSON(context.Background(), &SectionWithAPIOpts{Sections: []string{RouteSJSON}}, &reply); err != nil { t.Error(err) @@ -5957,7 +5957,7 @@ func TestSetCfgInDb(t *testing.T) { String_indexed_fields: &[]string{"field2"}, Suffix_indexed_fields: &[]string{"field2"}, Prefix_indexed_fields: &[]string{"field2"}, - Default_opts: map[string]interface{}{ + Opts: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(3), }, Nested_fields: utils.BoolPointer(false), @@ -5973,7 +5973,7 @@ func TestSetCfgInDb(t *testing.T) { String_indexed_fields: &[]string{"field2"}, Suffix_indexed_fields: &[]string{"field2"}, Prefix_indexed_fields: &[]string{"field2"}, - Default_opts: map[string]interface{}{ + Opts: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(3), }, Nested_fields: utils.BoolPointer(false), @@ -6019,7 +6019,7 @@ func TestSetNilCfgInDb(t *testing.T) { }, } expected := &AttributeSJsonCfg{ - Default_opts: make(map[string]interface{}), + Opts: make(map[string]interface{}), } var reply string if err := cfg.V1SetConfig(context.Background(), args, &reply); err != nil { @@ -6066,7 +6066,7 @@ func TestReloadCfgInDb(t *testing.T) { String_indexed_fields: &[]string{"field2"}, Suffix_indexed_fields: &[]string{"field2"}, Prefix_indexed_fields: &[]string{"field2"}, - Default_opts: map[string]interface{}{ + Opts: map[string]interface{}{ utils.OptsAttributesProcessRuns: float64(3), }, Nested_fields: utils.BoolPointer(false), diff --git a/config/routescfg.go b/config/routescfg.go index d67818e3a..3d1a465ab 100644 --- a/config/routescfg.go +++ b/config/routescfg.go @@ -45,8 +45,7 @@ type RouteSCfg struct { RateSConns []string AccountSConns []string DefaultRatio int - DefaultOpts *RoutesOpts - // DefaultOpts map[string]interface{} + Opts *RoutesOpts } func (rtsOpts *RoutesOpts) loadFromJSONCfg(jsnCfg *RoutesOptsJson) (err error) { @@ -113,8 +112,8 @@ func (rts *RouteSCfg) loadFromJSONCfg(jsnCfg *RouteSJsonCfg) (err error) { if jsnCfg.Default_ratio != nil { rts.DefaultRatio = *jsnCfg.Default_ratio } - if jsnCfg.Default_opts != nil { - rts.DefaultOpts.loadFromJSONCfg(jsnCfg.Default_opts) + if jsnCfg.Opts != nil { + rts.Opts.loadFromJSONCfg(jsnCfg.Opts) } if jsnCfg.Nested_fields != nil { rts.NestedFields = *jsnCfg.Nested_fields @@ -125,16 +124,16 @@ func (rts *RouteSCfg) loadFromJSONCfg(jsnCfg *RouteSJsonCfg) (err error) { // AsMapInterface returns the config as a map[string]interface{} func (rts *RouteSCfg) AsMapInterface() (initialMP map[string]interface{}) { opts := map[string]interface{}{ - utils.OptsContext: rts.DefaultOpts.Context, - utils.MetaProfileCountCfg: rts.DefaultOpts.ProfileCount, - utils.MetaIgnoreErrorsCfg: rts.DefaultOpts.IgnoreErrors, - utils.MetaMaxCostCfg: rts.DefaultOpts.MaxCost, + utils.OptsContext: rts.Opts.Context, + utils.MetaProfileCountCfg: rts.Opts.ProfileCount, + utils.MetaIgnoreErrorsCfg: rts.Opts.IgnoreErrors, + utils.MetaMaxCostCfg: rts.Opts.MaxCost, } - if rts.DefaultOpts.Limit != nil { - opts[utils.MetaLimitCfg] = *rts.DefaultOpts.Limit + if rts.Opts.Limit != nil { + opts[utils.MetaLimitCfg] = *rts.Opts.Limit } - if rts.DefaultOpts.Offset != nil { - opts[utils.MetaOffsetCfg] = *rts.DefaultOpts.Offset + if rts.Opts.Offset != nil { + opts[utils.MetaOffsetCfg] = *rts.Opts.Offset } initialMP = map[string]interface{}{ @@ -142,7 +141,7 @@ func (rts *RouteSCfg) AsMapInterface() (initialMP map[string]interface{}) { utils.IndexedSelectsCfg: rts.IndexedSelects, utils.DefaultRatioCfg: rts.DefaultRatio, utils.NestedFieldsCfg: rts.NestedFields, - utils.DefaultOptsCfg: opts, + utils.OptsCfg: opts, } if rts.StringIndexedFields != nil { initialMP[utils.StringIndexedFieldsCfg] = utils.CloneStringSlice(*rts.StringIndexedFields) @@ -178,7 +177,7 @@ func (rts RouteSCfg) Clone() (cln *RouteSCfg) { IndexedSelects: rts.IndexedSelects, DefaultRatio: rts.DefaultRatio, NestedFields: rts.NestedFields, - DefaultOpts: rts.DefaultOpts, + Opts: rts.Opts, } if rts.AttributeSConns != nil { cln.AttributeSConns = utils.CloneStringSlice(rts.AttributeSConns) @@ -230,8 +229,7 @@ type RouteSJsonCfg struct { Rates_conns *[]string Accounts_conns *[]string Default_ratio *int - Default_opts *RoutesOptsJson - // Default_opts map[string]interface{} + Opts *RoutesOptsJson } func diffRouteSJsonCfg(d *RouteSJsonCfg, v1, v2 *RouteSCfg) *RouteSJsonCfg { @@ -268,24 +266,24 @@ func diffRouteSJsonCfg(d *RouteSJsonCfg, v1, v2 *RouteSCfg) *RouteSJsonCfg { if v1.DefaultRatio != v2.DefaultRatio { d.Default_ratio = utils.IntPointer(v2.DefaultRatio) } - d.Default_opts = &RoutesOptsJson{} - if v1.DefaultOpts.Context != v2.DefaultOpts.Context { - d.Default_opts.Context = utils.StringPointer(v2.DefaultOpts.Context) + d.Opts = &RoutesOptsJson{} + if v1.Opts.Context != v2.Opts.Context { + d.Opts.Context = utils.StringPointer(v2.Opts.Context) } - if v1.DefaultOpts.Limit != v2.DefaultOpts.Limit { - d.Default_opts.Limit = v2.DefaultOpts.Limit + if v1.Opts.Limit != v2.Opts.Limit { + d.Opts.Limit = v2.Opts.Limit } - if v1.DefaultOpts.Offset != v2.DefaultOpts.Offset { - d.Default_opts.Offset = v2.DefaultOpts.Offset + if v1.Opts.Offset != v2.Opts.Offset { + d.Opts.Offset = v2.Opts.Offset } - if v1.DefaultOpts.MaxCost != v2.DefaultOpts.MaxCost { - d.Default_opts.MaxCost = &v2.DefaultOpts.MaxCost + if v1.Opts.MaxCost != v2.Opts.MaxCost { + d.Opts.MaxCost = &v2.Opts.MaxCost } - if v1.DefaultOpts.IgnoreErrors != v2.DefaultOpts.IgnoreErrors { - d.Default_opts.IgnoreErrors = utils.BoolPointer(v2.DefaultOpts.IgnoreErrors) + if v1.Opts.IgnoreErrors != v2.Opts.IgnoreErrors { + d.Opts.IgnoreErrors = utils.BoolPointer(v2.Opts.IgnoreErrors) } - if v1.DefaultOpts.ProfileCount != v2.DefaultOpts.ProfileCount { - d.Default_opts.ProfileCount = utils.Float64Pointer(v2.DefaultOpts.ProfileCount) + if v1.Opts.ProfileCount != v2.Opts.ProfileCount { + d.Opts.ProfileCount = utils.Float64Pointer(v2.Opts.ProfileCount) } return d } diff --git a/config/routescfg_test.go b/config/routescfg_test.go index 21d166bb5..e48e4ac11 100644 --- a/config/routescfg_test.go +++ b/config/routescfg_test.go @@ -52,7 +52,7 @@ func TestRouteSCfgloadFromJsonCfg(t *testing.T) { AccountSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaAccounts), "conn1"}, DefaultRatio: 10, NestedFields: true, - DefaultOpts: &RoutesOpts{ + Opts: &RoutesOpts{ Context: utils.MetaRoutes, ProfileCount: float64(1), IgnoreErrors: false, @@ -83,7 +83,7 @@ func TestRouteSCfgAsMapInterface(t *testing.T) { utils.RateSConnsCfg: []string{}, utils.AccountSConnsCfg: []string{}, utils.DefaultRatioCfg: 1, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsContext: utils.MetaRoutes, utils.MetaProfileCountCfg: float64(1), utils.MetaIgnoreErrorsCfg: false, @@ -128,7 +128,7 @@ func TestRouteSCfgAsMapInterface1(t *testing.T) { utils.RateSConnsCfg: []string{utils.MetaInternal, "conn1"}, utils.AccountSConnsCfg: []string{utils.MetaInternal, "conn1"}, utils.DefaultRatioCfg: 2, - utils.DefaultOptsCfg: map[string]interface{}{ + utils.OptsCfg: map[string]interface{}{ utils.OptsContext: utils.MetaRoutes, utils.MetaProfileCountCfg: float64(1), utils.MetaIgnoreErrorsCfg: false, @@ -193,7 +193,7 @@ func TestDiffRouteSJsonCfg(t *testing.T) { ResourceSConns: []string{"*localhost"}, StatSConns: []string{"*localhost"}, DefaultRatio: 2, - DefaultOpts: &RoutesOpts{ + Opts: &RoutesOpts{ Context: utils.MetaAny, IgnoreErrors: true, MaxCost: 5, @@ -214,7 +214,7 @@ func TestDiffRouteSJsonCfg(t *testing.T) { ResourceSConns: []string{"*birpc"}, StatSConns: []string{"*birpc"}, DefaultRatio: 3, - DefaultOpts: &RoutesOpts{ + Opts: &RoutesOpts{ Context: utils.MetaRoutes, IgnoreErrors: false, MaxCost: utils.MetaEventCost, @@ -235,10 +235,10 @@ func TestDiffRouteSJsonCfg(t *testing.T) { Resources_conns: &[]string{"*birpc"}, Stats_conns: &[]string{"*birpc"}, Default_ratio: utils.IntPointer(3), - Default_opts: &RoutesOptsJson{ + Opts: &RoutesOptsJson{ Context: utils.StringPointer(utils.MetaRoutes), IgnoreErrors: utils.BoolPointer(false), - MaxCost: &v2.DefaultOpts.MaxCost, + MaxCost: &v2.Opts.MaxCost, Limit: utils.IntPointer(2), Offset: utils.IntPointer(2), ProfileCount: utils.Float64Pointer(2), @@ -252,7 +252,7 @@ func TestDiffRouteSJsonCfg(t *testing.T) { v1 = v2 expected = &RouteSJsonCfg{ - Default_opts: &RoutesOptsJson{}, + Opts: &RoutesOptsJson{}, } rcv = diffRouteSJsonCfg(d, v1, v2) if !reflect.DeepEqual(rcv, expected) { diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json index 9cb1afd66..bf7f7382a 100755 --- a/data/conf/cgrates/cgrates.json +++ b/data/conf/cgrates/cgrates.json @@ -646,7 +646,7 @@ // "prefix_indexed_fields": [], // query indexes based on these fields for faster processing // "suffix_indexed_fields": [], // query indexes based on these fields for faster processing // "nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level) -// "default_opts":{ // +// "opts":{ // // "*processRuns": 1, // number of run loops when processing event // }, // "profile_runs": 0, // number of run a profile will process the event @@ -714,7 +714,7 @@ // "rates_conns": [], // connections to RateS // "accounts_conns": [], // connections to AccountS // "default_ratio":1, // default ratio used in case of *load strategy -// "default_opts":{ +// "opts":{ // "*context": "*routes", // "*rouProfileCount": 1, // }, diff --git a/data/conf/samples/cluelrn/cgrates.json b/data/conf/samples/cluelrn/cgrates.json index 278ea212c..1589da5a0 100644 --- a/data/conf/samples/cluelrn/cgrates.json +++ b/data/conf/samples/cluelrn/cgrates.json @@ -24,7 +24,7 @@ "stor_db": { - "db_password": "CGRateS.org", + "db_password": "CGRateS.org" }, @@ -45,8 +45,8 @@ "attributes": { "enabled": true, - "default_opts":{ - "*processRuns": 5, // number of run loops when processing event + "opts":{ + "*processRuns": 5 // number of run loops when processing event }, }, diff --git a/engine/routes.go b/engine/routes.go index 5afd3ad2a..a2fa633ff 100644 --- a/engine/routes.go +++ b/engine/routes.go @@ -269,7 +269,7 @@ func (rpS *RouteService) V1GetRoutes(ctx *context.Context, args *utils.CGREvent, args.APIOpts[utils.Subsys] = utils.MetaRoutes args.APIOpts[utils.OptsContext] = utils.FirstNonEmpty( utils.IfaceAsString(args.APIOpts[utils.OptsContext]), - rpS.cfg.RouteSCfg().DefaultOpts.Context, + rpS.cfg.RouteSCfg().Opts.Context, utils.MetaRoutes) attrArgs := &AttrArgsProcessEvent{ CGREvent: args, @@ -390,7 +390,7 @@ func (rpS *RouteService) sortedRoutesForEvent(ctx *context.Context, tnt string, prfCount := len(rPrfs) // if the option is not present return for all profiles prfCountOptInf, has := args.APIOpts[utils.OptsRoutesProfileCount] if !has { - prfCountOptInf = rpS.cfg.RouteSCfg().DefaultOpts.ProfileCount + prfCountOptInf = rpS.cfg.RouteSCfg().Opts.ProfileCount } if prfCountOptInf != nil { prfCountOpt, err := utils.IfaceAsTInt64(prfCountOptInf) @@ -401,7 +401,7 @@ func (rpS *RouteService) sortedRoutesForEvent(ctx *context.Context, tnt string, } } var extraOpts *optsGetRoutes - if extraOpts, err = newOptsGetRoutes(args, rpS.cfg.RouteSCfg().DefaultOpts); err != nil { // convert routes arguments into internal options used to limit data + if extraOpts, err = newOptsGetRoutes(args, rpS.cfg.RouteSCfg().Opts); err != nil { // convert routes arguments into internal options used to limit data return } diff --git a/engine/routes_test.go b/engine/routes_test.go index 9d2abd853..1c18a212f 100644 --- a/engine/routes_test.go +++ b/engine/routes_test.go @@ -1482,7 +1482,7 @@ func TestRoutesNewOptsGetRoutes(t *testing.T) { maxCost: 10.0, paginator: &utils.Paginator{}, } - sprf, err := newOptsGetRoutes(ev, config.CgrConfig().RouteSCfg().DefaultOpts) + sprf, err := newOptsGetRoutes(ev, config.CgrConfig().RouteSCfg().Opts) if err != nil { t.Errorf("Error: %+v", err) } @@ -1492,7 +1492,7 @@ func TestRoutesNewOptsGetRoutes(t *testing.T) { } func TestRoutesNewOptsGetRoutesFromCfg(t *testing.T) { - config.CgrConfig().RouteSCfg().DefaultOpts.IgnoreErrors = true + config.CgrConfig().RouteSCfg().Opts.IgnoreErrors = true ev := &utils.CGREvent{ APIOpts: map[string]interface{}{}, } @@ -1500,7 +1500,7 @@ func TestRoutesNewOptsGetRoutesFromCfg(t *testing.T) { ignoreErrors: true, paginator: &utils.Paginator{}, } - sprf, err := newOptsGetRoutes(ev, config.CgrConfig().RouteSCfg().DefaultOpts) + sprf, err := newOptsGetRoutes(ev, config.CgrConfig().RouteSCfg().Opts) if err != nil { t.Errorf("Error: %+v", err) } @@ -1519,7 +1519,7 @@ func TestRoutesNewOptsGetRoutesIgnoreErrors(t *testing.T) { ignoreErrors: true, paginator: &utils.Paginator{}, } - sprf, err := newOptsGetRoutes(ev, config.CgrConfig().RouteSCfg().DefaultOpts) + sprf, err := newOptsGetRoutes(ev, config.CgrConfig().RouteSCfg().Opts) if err != nil { t.Errorf("Error: %+v", err) } diff --git a/general_tests/all_cfg_rld_it_test.go b/general_tests/all_cfg_rld_it_test.go index 08663c7d8..59b118651 100644 --- a/general_tests/all_cfg_rld_it_test.go +++ b/general_tests/all_cfg_rld_it_test.go @@ -292,7 +292,7 @@ func testConfigSReload(t *testing.T) { t.Errorf("\nExpected %+v ,\n received: %+v", utils.ToIJSON(cfgStr), utils.ToIJSON(rpl19)) } - cfgStr = "{\"attributes\":{\"any_context\":true,\"accounts_conns\":[\"*localhost\"],\"default_opts\":{\"*processRuns\":2},\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":false,\"prefix_indexed_fields\":[],\"resources_conns\":[\"*localhost\"],\"stats_conns\":[\"*localhost\"],\"suffix_indexed_fields\":[]}}" + cfgStr = "{\"attributes\":{\"any_context\":true,\"accounts_conns\":[\"*localhost\"],\"opts\":{\"*processRuns\":2},\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":false,\"prefix_indexed_fields\":[],\"resources_conns\":[\"*localhost\"],\"stats_conns\":[\"*localhost\"],\"suffix_indexed_fields\":[]}}" var rpl20 string if err := testRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{ Tenant: "cgrates.org", diff --git a/general_tests/all_sections_cfg_rld_it_test.go b/general_tests/all_sections_cfg_rld_it_test.go index d7c45d2eb..6f2bea4cc 100644 --- a/general_tests/all_sections_cfg_rld_it_test.go +++ b/general_tests/all_sections_cfg_rld_it_test.go @@ -665,13 +665,13 @@ func testSectConfigSReloadAttributes(t *testing.T) { var reply string if err := testSectRPC.Call(context.Background(), utils.ConfigSv1SetConfigFromJSON, &config.SetConfigFromJSONArgs{ Tenant: "cgrates.org", - Config: "{\"attributes\":{\"any_context\":true,\"accounts_conns\":[\"*localhost\"],\"default_opts\":{\"*processRuns\":2},\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":false,\"prefix_indexed_fields\":[],\"resources_conns\":[\"*localhost\"],\"stats_conns\":[\"*localhost\"],\"suffix_indexed_fields\":[]}}", + Config: "{\"attributes\":{\"any_context\":true,\"accounts_conns\":[\"*localhost\"],\"opts\":{\"*processRuns\":2},\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":false,\"prefix_indexed_fields\":[],\"resources_conns\":[\"*localhost\"],\"stats_conns\":[\"*localhost\"],\"suffix_indexed_fields\":[]}}", }, &reply); err != nil { t.Error(err) } else if reply != utils.OK { t.Errorf("Expected OK received: %+v", reply) } - cfgStr := "{\"attributes\":{\"any_context\":true,\"accounts_conns\":[\"*localhost\"],\"default_opts\":{\"*processRuns\":2},\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":false,\"prefix_indexed_fields\":[],\"resources_conns\":[\"*localhost\"],\"stats_conns\":[\"*localhost\"],\"suffix_indexed_fields\":[]}}" + cfgStr := "{\"attributes\":{\"any_context\":true,\"accounts_conns\":[\"*localhost\"],\"opts\":{\"*processRuns\":2},\"enabled\":true,\"indexed_selects\":true,\"nested_fields\":false,\"prefix_indexed_fields\":[],\"resources_conns\":[\"*localhost\"],\"stats_conns\":[\"*localhost\"],\"suffix_indexed_fields\":[]}}" var rpl string if err := testSectRPC.Call(context.Background(), utils.ConfigSv1GetConfigAsJSON, &config.SectionWithAPIOpts{ Tenant: "cgrates.org", diff --git a/utils/consts.go b/utils/consts.go index 21486f161..821d17449 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -1225,6 +1225,7 @@ const ( CoreSv1 = "CoreSv1" CoreSv1Status = "CoreSv1.Status" CoreSv1Ping = "CoreSv1.Ping" + CoreSv1Shutdown = "CoreSv1.Shutdown" CoreSv1Sleep = "CoreSv1.Sleep" CoreSv1StartCPUProfiling = "CoreSv1.StartCPUProfiling" CoreSv1StopCPUProfiling = "CoreSv1.StopCPUProfiling" @@ -1896,7 +1897,6 @@ const ( TpOutDirCfg = "tp_out_dir" DataCfg = "data" - DefaultOptsCfg = "default_opts" DefaultRatioCfg = "default_ratio" ReadersCfg = "readers" ExportersCfg = "exporters"