diff --git a/apis/filter_indexes.go b/apis/filter_indexes.go
index 1f15cc875..aaaa5f6a2 100644
--- a/apis/filter_indexes.go
+++ b/apis/filter_indexes.go
@@ -347,7 +347,7 @@ func (adms *AdminSv1) ComputeFilterIndexes(cntxt *context.Context, args *utils.A
cacheIDs[utils.DispatcherFilterIndexIDs] = []string{utils.MetaAny}
if indexes, err = engine.ComputeIndexes(cntxt, adms.dm, tnt, args.Context, utils.CacheDispatcherFilterIndexes,
nil, transactionID, func(tnt, id, ctx string) (*[]string, error) {
- dsp, e := adms.dm.GetDispatcherProfile(tnt, id, true, false, utils.NonTransactional)
+ dsp, e := adms.dm.GetDispatcherProfile(cntxt, tnt, id, true, false, utils.NonTransactional)
if e != nil {
return nil, e
}
@@ -556,7 +556,7 @@ func (adms *AdminSv1) ComputeFilterIndexIDs(cntxt *context.Context, args *utils.
//DispatcherProfile Indexes
if indexes, err = engine.ComputeIndexes(cntxt, adms.dm, tnt, args.Context, utils.CacheDispatcherFilterIndexes,
&args.DispatcherIDs, transactionID, func(tnt, id, ctx string) (*[]string, error) {
- dsp, e := adms.dm.GetDispatcherProfile(tnt, id, true, false, utils.NonTransactional)
+ dsp, e := adms.dm.GetDispatcherProfile(cntxt, tnt, id, true, false, utils.NonTransactional)
if e != nil {
return nil, e
}
diff --git a/apis/filter_indexes_it_test.go b/apis/filter_indexes_it_test.go
index 05cb2dc8b..d107f6a84 100644
--- a/apis/filter_indexes_it_test.go
+++ b/apis/filter_indexes_it_test.go
@@ -500,6 +500,7 @@ func testV1FIdxAttributeMoreProfilesForFilters(t *testing.T) {
FilterIDs: []string{"fltr_for_attr3"},
Attributes: []*engine.ExternalAttribute{
{
+ Path: "*req.Destinations",
Type: utils.MetaConstant,
Value: "1008",
},
diff --git a/apis/filters.go b/apis/filters.go
index 849bc1ded..72122fd25 100644
--- a/apis/filters.go
+++ b/apis/filters.go
@@ -24,24 +24,38 @@ import (
)
//SetFilter add a new Filter
-func (adms *AdminSv1) SetFilter(ctx *context.Context, arg *engine.FilterWithAPIOpts, reply *string) error {
+func (adms *AdminSv1) SetFilter(ctx *context.Context, arg *engine.FilterWithAPIOpts, reply *string) (err error) {
if missing := utils.MissingStructFields(arg.Filter, []string{utils.ID}); len(missing) != 0 {
return utils.NewErrMandatoryIeMissing(missing...)
}
if arg.Tenant == utils.EmptyString {
arg.Tenant = adms.cfg.GeneralCfg().DefaultTenant
}
+ tntID := arg.TenantID()
+ argC := map[string][]string{utils.FilterIDs: {tntID}}
+ if fltr, err := adms.dm.GetFilter(ctx, arg.Filter.Tenant, arg.Filter.ID, true, false, utils.NonTransactional); err != nil {
+ if err != utils.ErrNotFound {
+ return utils.APIErrorHandler(err)
+ }
+ } else if argC, err = composeCacheArgsForFilter(adms.dm, ctx, fltr, fltr.Tenant, tntID, argC); err != nil {
+ return utils.APIErrorHandler(err)
+ }
if err := adms.dm.SetFilter(ctx, arg.Filter, true); err != nil {
return utils.APIErrorHandler(err)
}
+ if argC, err = composeCacheArgsForFilter(adms.dm, ctx, arg.Filter, arg.Filter.Tenant, tntID, argC); err != nil {
+ return utils.APIErrorHandler(err)
+ }
//generate a loadID for CacheFilters and store it in database
if err := adms.dm.SetLoadIDs(ctx,
map[string]int64{utils.CacheFilters: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
//handle caching for Filter
- if err := adms.CallCache(ctx, utils.IfaceAsString(arg.APIOpts[utils.CacheOpt]), arg.Tenant, utils.CacheFilters,
- arg.TenantID(), nil, nil, arg.APIOpts); err != nil {
+ if err := callCacheForFilter(adms.connMgr, adms.cfg.AdminSCfg().CachesConns, ctx,
+ utils.IfaceAsString(arg.APIOpts[utils.CacheOpt]),
+ adms.cfg.GeneralCfg().DefaultCaching,
+ arg.Tenant, argC, arg.APIOpts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
@@ -104,8 +118,10 @@ func (adms *AdminSv1) RemoveFilter(ctx *context.Context, arg *utils.TenantIDWith
return utils.APIErrorHandler(err)
}
//handle caching for Filter
- if err := adms.CallCache(ctx, utils.IfaceAsString(arg.APIOpts[utils.CacheOpt]), tnt, utils.CacheFilters,
- utils.ConcatenatedKey(tnt, arg.ID), nil, nil, arg.APIOpts); err != nil {
+ if err := callCacheForFilter(adms.connMgr, adms.cfg.AdminSCfg().CachesConns, ctx,
+ utils.IfaceAsString(arg.APIOpts[utils.CacheOpt]),
+ adms.cfg.GeneralCfg().DefaultCaching,
+ arg.Tenant, map[string][]string{utils.FilterIDs: {utils.ConcatenatedKey(tnt, arg.ID)}}, arg.APIOpts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
diff --git a/apis/libadmin.go b/apis/libadmin.go
index 727afae55..20109b34d 100644
--- a/apis/libadmin.go
+++ b/apis/libadmin.go
@@ -252,3 +252,103 @@ func (apierSv1 *AdminS) callCacheMultiple(cacheopt, tnt, cacheID string, itemIDs
method, args, &reply)
}
*/
+
+func composeCacheArgsForFilter(dm *engine.DataManager, ctx *context.Context, fltr *engine.Filter, tnt, tntID string, args map[string][]string) (_ map[string][]string, err error) {
+ indxIDs := make([]string, 0, len(fltr.Rules))
+ for _, flt := range fltr.Rules {
+ if !engine.FilterIndexTypes.Has(flt.Type) {
+ continue
+ }
+ isDyn := strings.HasPrefix(flt.Element, utils.DynamicDataPrefix)
+ for _, fldVal := range flt.Values {
+ if isDyn {
+ if !strings.HasPrefix(fldVal, utils.DynamicDataPrefix) {
+ indxIDs = append(indxIDs, utils.ConcatenatedKey(flt.Type, flt.Element[1:], fldVal))
+ }
+ } else if strings.HasPrefix(fldVal, utils.DynamicDataPrefix) {
+ indxIDs = append(indxIDs, utils.ConcatenatedKey(flt.Type, fldVal[1:], flt.Element))
+ }
+ }
+ }
+ if len(indxIDs) == 0 { // no index
+ return args, nil
+ }
+
+ var rcvIndx map[string]utils.StringSet
+ if rcvIndx, err = dm.GetIndexes(ctx, utils.CacheReverseFilterIndexes, tntID,
+ utils.EmptyString, true, true); err != nil && err != utils.ErrNotFound { // error when geting the revers
+ return
+ }
+ if err == utils.ErrNotFound || len(rcvIndx) == 0 { // no reverse index for this filter
+ return args, nil
+ }
+
+ for k, ids := range rcvIndx {
+ switch k {
+ default:
+ if cField, has := utils.CacheInstanceToArg[k]; has {
+ for _, indx := range indxIDs {
+ args[cField] = append(args[cField], utils.ConcatenatedKey(tnt, indx))
+ }
+ }
+ case utils.CacheAttributeFilterIndexes: // this is slow
+ for attrID := range ids {
+ var attr *engine.AttributeProfile
+ if attr, err = dm.GetAttributeProfile(ctx, tnt, attrID, true, true, utils.NonTransactional); err != nil {
+ return
+ }
+ for _, ctx := range attr.Contexts {
+ for _, indx := range indxIDs {
+ args[utils.AttributeFilterIndexIDs] = append(args[utils.AttributeFilterIndexIDs], utils.ConcatenatedKey(tnt, ctx, indx))
+ }
+ }
+ }
+ case utils.CacheDispatcherFilterIndexes: // this is slow
+ for attrID := range ids {
+ var attr *engine.DispatcherProfile
+ if attr, err = dm.GetDispatcherProfile(ctx, tnt, attrID, true, true, utils.NonTransactional); err != nil {
+ return
+ }
+ for _, ctx := range attr.Subsystems {
+ for _, indx := range indxIDs {
+ args[utils.DispatcherFilterIndexIDs] = append(args[utils.DispatcherFilterIndexIDs], utils.ConcatenatedKey(tnt, ctx, indx))
+ }
+ }
+ }
+ }
+ }
+ return args, nil
+}
+
+// callCacheForFilter will call the cache for filter
+func callCacheForFilter(connMgr *engine.ConnManager, cacheConns []string, ctx *context.Context, cacheopt, dftCache, tnt string,
+ argC map[string][]string, opts map[string]interface{}) (err error) {
+ var reply, method string
+ var args interface{} = &utils.AttrReloadCacheWithAPIOpts{
+ Tenant: tnt,
+ ArgsCache: argC,
+ APIOpts: opts,
+ }
+ switch utils.FirstNonEmpty(cacheopt, dftCache) {
+ case utils.MetaNone:
+ return
+ case utils.MetaReload:
+ method = utils.CacheSv1ReloadCache
+ case utils.MetaLoad:
+ method = utils.CacheSv1LoadCache
+ case utils.MetaRemove:
+ method = utils.CacheSv1RemoveItems
+ case utils.MetaClear:
+ cacheIDs := make([]string, 0, len(argC))
+ for k := range argC {
+ cacheIDs = append(cacheIDs, utils.ArgCacheToInstance[k])
+ }
+ method = utils.CacheSv1Clear
+ args = &utils.AttrCacheIDsWithAPIOpts{
+ Tenant: tnt,
+ CacheIDs: cacheIDs,
+ APIOpts: opts,
+ }
+ }
+ return connMgr.Call(ctx, cacheConns, method, args, &reply)
+}
diff --git a/apis/libadmin_test.go b/apis/libadmin_test.go
new file mode 100644
index 000000000..1c1fe6e2d
--- /dev/null
+++ b/apis/libadmin_test.go
@@ -0,0 +1,105 @@
+/*
+Real-time Online/Offline Charging System (OerS) for Telecom & ISP environments
+Copyright (C) ITsysCOM GmbH
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package apis
+
+import (
+ "reflect"
+ "testing"
+
+ "github.com/cgrates/birpc/context"
+ "github.com/cgrates/cgrates/config"
+ "github.com/cgrates/cgrates/engine"
+ "github.com/cgrates/cgrates/utils"
+)
+
+func TestCallCacheForFilter(t *testing.T) {
+ cfg := config.NewDefaultCGRConfig()
+ dm := engine.NewDataManager(engine.NewInternalDB(nil, nil, true), cfg.CacheCfg(), nil)
+ tnt := "cgrates.org"
+ flt := &engine.Filter{
+ Tenant: tnt,
+ ID: "FLTR1",
+ Rules: []*engine.FilterRule{{
+ Type: utils.MetaString,
+ Element: "~*req.Account",
+ Values: []string{"1001"},
+ }},
+ }
+ if err := flt.Compile(); err != nil {
+ t.Fatal(err)
+ }
+ if err := dm.SetFilter(context.TODO(), flt, true); err != nil {
+ t.Fatal(err)
+ }
+ th := &engine.ThresholdProfile{
+ Tenant: tnt,
+ ID: "TH1",
+ FilterIDs: []string{flt.ID},
+ }
+ if err := dm.SetThresholdProfile(th, true); err != nil {
+ t.Fatal(err)
+ }
+ attr := &engine.AttributeProfile{
+ Tenant: tnt,
+ ID: "Attr1",
+ Contexts: []string{utils.MetaAny},
+ FilterIDs: []string{flt.ID},
+ }
+ if err := dm.SetAttributeProfile(context.TODO(), attr, true); err != nil {
+ t.Fatal(err)
+ }
+
+ exp := map[string][]string{
+ utils.FilterIDs: {"cgrates.org:FLTR1"},
+ utils.AttributeFilterIndexIDs: {"cgrates.org:*any:*string:*req.Account:1001"},
+ utils.ThresholdFilterIndexIDs: {"cgrates.org:*string:*req.Account:1001"},
+ }
+ rpl, err := composeCacheArgsForFilter(dm, context.TODO(), flt, tnt, flt.TenantID(), map[string][]string{utils.FilterIDs: {"cgrates.org:FLTR1"}})
+ if err != nil {
+ t.Fatal(err)
+ } else if !reflect.DeepEqual(rpl, exp) {
+ t.Errorf("Expected %s ,received: %s", utils.ToJSON(exp), utils.ToJSON(rpl))
+ }
+ flt = &engine.Filter{
+ Tenant: tnt,
+ ID: "FLTR1",
+ Rules: []*engine.FilterRule{{
+ Type: utils.MetaString,
+ Element: "~*req.Account",
+ Values: []string{"1002"},
+ }},
+ }
+ if err := flt.Compile(); err != nil {
+ t.Fatal(err)
+ }
+ if err := dm.SetFilter(context.TODO(), flt, true); err != nil {
+ t.Fatal(err)
+ }
+ exp = map[string][]string{
+ utils.FilterIDs: {"cgrates.org:FLTR1"},
+ utils.AttributeFilterIndexIDs: {"cgrates.org:*any:*string:*req.Account:1001", "cgrates.org:*any:*string:*req.Account:1002"},
+ utils.ThresholdFilterIndexIDs: {"cgrates.org:*string:*req.Account:1001", "cgrates.org:*string:*req.Account:1002"},
+ }
+ rpl, err = composeCacheArgsForFilter(dm, context.TODO(), flt, tnt, flt.TenantID(), rpl)
+ if err != nil {
+ t.Fatal(err)
+ } else if !reflect.DeepEqual(rpl, exp) {
+ t.Errorf("Expected %s ,received: %s", utils.ToJSON(exp), utils.ToJSON(rpl))
+ }
+}
diff --git a/config/config_test.go b/config/config_test.go
index be41515f6..2fc2d2a51 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -5272,7 +5272,7 @@ func TestV1GetConfigAsJSONAllConfig(t *testing.T) {
}
}`
var reply string
- expected := ` expected := `{"accounts":{"attributes_conns":[],"enabled":false,"indexed_selects":true,"max_iterations":1000,"max_usage":"259200000000000","nested_fields":false,"prefix_indexed_fields":[],"rates_conns":[],"suffix_indexed_fields":[],"thresholds_conns":[]},"actions":{"accounts_conns":[],"cdrs_conns":[],"ees_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"stats_conns":[],"suffix_indexed_fields":[],"tenants":[],"thresholds_conns":[]},"admins":{"actions_conns":[],"attributes_conns":[],"caches_conns":["*internal"],"ees_conns":[],"enabled":false},"analyzers":{"cleanup_interval":"1h0m0s","db_path":"/var/spool/cgrates/analyzers","enabled":false,"index_type":"*scorch","ttl":"24h0m0s"},"apiban":{"enabled":false,"keys":[]},"asterisk_agent":{"asterisk_conns":[{"address":"127.0.0.1:8088","alias":"","connect_attempts":3,"password":"CGRateS.org","reconnects":5,"user":"cgrates"}],"create_cdr":false,"enabled":false,"sessions_conns":["*birpc_internal"]},"attributes":{"admins_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"process_runs":1,"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*apiban":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*attribute_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*caps_events":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*cdr_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*cdrs":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*charger_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*charger_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*closed_sessions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_loads":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*event_charges":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*load_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rate_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*replication_hosts":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resource_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resource_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*reverse_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*route_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*route_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rpc_connections":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rpc_responses":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*session_costs":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*stat_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*statqueue_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*statqueues":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*stir":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*threshold_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_attributes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_chargers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_stats":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*uch":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*versions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""}},"replication_conns":[]},"cdrs":{"actions_conns":[],"attributes_conns":[],"chargers_conns":[],"ees_conns":[],"enabled":false,"extra_fields":[],"online_cdr_exports":[],"session_cost_retries":5,"stats_conns":[],"store_cdrs":true,"thresholds_conns":[]},"chargers":{"attributes_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"config_db":{"db_host":"","db_name":"","db_password":"","db_port":0,"db_type":"*internal","db_user":"","items":{},"opts":{"query_timeout":"10s","redis_ca_certificate":"","redis_client_certificate":"","redis_client_key":"","redis_cluster":false,"redis_cluster_ondown_delay":"0","redis_cluster_sync":"5s","redis_sentinel":"","redis_tls":false},"remote_conn_id":"","remote_conns":null,"replication_cache":"","replication_conns":null,"replication_filtered":false},"configs":{"enabled":false,"root_dir":"/var/spool/cgrates/configs","url":"/configs/"},"cores":{"caps":0,"caps_stats_interval":"0","caps_strategy":"*busy","shutdown_timeout":"1s"},"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*accounts":{"remote":false,"replicate":false},"*action_profiles":{"remote":false,"replicate":false},"*actions":{"remote":false,"replicate":false},"*attribute_profiles":{"remote":false,"replicate":false},"*charger_profiles":{"remote":false,"replicate":false},"*dispatcher_hosts":{"remote":false,"replicate":false},"*dispatcher_profiles":{"remote":false,"replicate":false},"*filters":{"remote":false,"replicate":false},"*indexes":{"remote":false,"replicate":false},"*load_ids":{"remote":false,"replicate":false},"*rate_profiles":{"remote":false,"replicate":false},"*resource_profiles":{"remote":false,"replicate":false},"*resources":{"remote":false,"replicate":false},"*route_profiles":{"remote":false,"replicate":false},"*statqueue_profiles":{"remote":false,"replicate":false},"*statqueues":{"remote":false,"replicate":false},"*threshold_profiles":{"remote":false,"replicate":false},"*thresholds":{"remote":false,"replicate":false}},"opts":{"mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false},"diameter_agent":{"asr_template":"","concurrent_requests":-1,"dictionaries_path":"/usr/share/cgrates/diameter/dict/","enabled":false,"forced_disconnect":"*none","listen":"127.0.0.1:3868","listen_net":"tcp","origin_host":"CGR-DA","origin_realm":"cgrates.org","product_name":"CGRateS","rar_template":"","request_processors":[],"sessions_conns":["*birpc_internal"],"synced_conn_requests":false,"vendor_id":0},"dispatchers":{"attributes_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"dns_agent":{"enabled":false,"listen":"127.0.0.1:2053","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"],"timezone":""},"ees":{"attributes_conns":[],"cache":{"*file_csv":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"enabled":false,"exporters":[{"attempts":1,"attribute_context":"","attribute_ids":[],"export_path":"/var/spool/cgrates/ees","fields":[],"filters":[],"flags":[],"id":"*default","opts":{},"synchronous":false,"tenant":"","timezone":"","type":"*none"}]},"ers":{"enabled":false,"partial_cache_action":"*none","partial_cache_ttl":"1s","partial_path":"","readers":[{"cache_dump_fields":[],"concurrent_requests":1024,"fields":[{"mandatory":true,"path":"*cgreq.ToR","tag":"ToR","type":"*variable","value":"~*req.2"},{"mandatory":true,"path":"*cgreq.OriginID","tag":"OriginID","type":"*variable","value":"~*req.3"},{"mandatory":true,"path":"*cgreq.RequestType","tag":"RequestType","type":"*variable","value":"~*req.4"},{"mandatory":true,"path":"*cgreq.Tenant","tag":"Tenant","type":"*variable","value":"~*req.6"},{"mandatory":true,"path":"*cgreq.Category","tag":"Category","type":"*variable","value":"~*req.7"},{"mandatory":true,"path":"*cgreq.Account","tag":"Account","type":"*variable","value":"~*req.8"},{"mandatory":true,"path":"*cgreq.Subject","tag":"Subject","type":"*variable","value":"~*req.9"},{"mandatory":true,"path":"*cgreq.Destination","tag":"Destination","type":"*variable","value":"~*req.10"},{"mandatory":true,"path":"*cgreq.SetupTime","tag":"SetupTime","type":"*variable","value":"~*req.11"},{"mandatory":true,"path":"*cgreq.AnswerTime","tag":"AnswerTime","type":"*variable","value":"~*req.12"},{"mandatory":true,"path":"*cgreq.Usage","tag":"Usage","type":"*variable","value":"~*req.13"}],"filters":[],"flags":[],"id":"*default","opts":{"csvFieldSeparator":",","csvHeaderDefineChar":":","csvRowLength":0,"partialOrderField":"~*req.AnswerTime","xmlRootPath":""},"partial_commit_fields":[],"processed_path":"/var/spool/cgrates/ers/out","run_delay":"0","source_path":"/var/spool/cgrates/ers/in","tenant":"","timezone":"","type":"*none"}],"sessions_conns":["*internal"]},"filters":{"admins_conns":[],"resources_conns":[],"stats_conns":[]},"freeswitch_agent":{"create_cdr":false,"empty_balance_ann_file":"","empty_balance_context":"","enabled":false,"event_socket_conns":[{"address":"127.0.0.1:8021","alias":"127.0.0.1:8021","password":"ClueCon","reconnects":5}],"extra_fields":[],"low_balance_ann_file":"","max_wait_connection":"2s","sessions_conns":["*birpc_internal"],"subscribe_park":true},"general":{"connect_attempts":5,"connect_timeout":"1s","dbdata_encoding":"*msgpack","default_caching":"*reload","default_category":"call","default_request_type":"*rated","default_tenant":"cgrates.org","default_timezone":"Local","digest_equal":":","digest_separator":",","failed_posts_dir":"/var/spool/cgrates/failed_posts","failed_posts_ttl":"5s","locking_timeout":"0","log_level":6,"logger":"*syslog","max_parallel_conns":100,"node_id":"ENGINE1","poster_attempts":3,"reconnects":-1,"reply_timeout":"2s","rounding_decimals":5,"rsr_separator":";","tpexport_dir":"/var/spool/cgrates/tpe"},"http":{"auth_users":{},"client_opts":{"dialFallbackDelay":"300ms","dialKeepAlive":"30s","dialTimeout":"30s","disableCompression":false,"disableKeepAlives":false,"expectContinueTimeout":"0","forceAttemptHttp2":true,"idleConnTimeout":"90s","maxConnsPerHost":0,"maxIdleConns":100,"maxIdleConnsPerHost":2,"responseHeaderTimeout":"0","skipTlsVerify":false,"tlsHandshakeTimeout":"10s"},"freeswitch_cdrs_url":"/freeswitch_json","http_cdrs":"/cdr_http","json_rpc_url":"/jsonrpc","registrars_url":"/registrar","use_basic_auth":false,"ws_url":"/ws"},"http_agent":[],"kamailio_agent":{"create_cdr":false,"enabled":false,"evapi_conns":[{"address":"127.0.0.1:8448","alias":"","reconnects":5}],"sessions_conns":["*birpc_internal"],"timezone":""},"listen":{"http":"127.0.0.1:2080","http_tls":"127.0.0.1:2280","rpc_gob":"127.0.0.1:2013","rpc_gob_tls":"127.0.0.1:2023","rpc_json":"127.0.0.1:2012","rpc_json_tls":"127.0.0.1:2022"},"loader":{"actions_conns":["*localhost"],"caches_conns":["*localhost"],"data_path":"./","disable_reverse":false,"field_separator":",","gapi_credentials":".gapi/credentials.json","gapi_token":".gapi/token.json","tpid":""},"loaders":[{"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"Contexts","tag":"Contexts","type":"*variable","value":"~*req.2"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.3"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.4"},{"path":"AttributeFilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Path","tag":"Path","type":"*variable","value":"~*req.6"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.7"},{"path":"Value","tag":"Value","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.6"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.7"},{"path":"MetricFilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionIDs","tag":"ActionIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.4"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.5"},{"path":"RouteID","tag":"RouteID","type":"*variable","value":"~*req.6"},{"path":"RouteFilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.7"},{"path":"RouteAccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.8"},{"path":"RouteRatingPlanIDs","tag":"RouteRatingPlanIDs","type":"*variable","value":"~*req.9"},{"path":"RouteResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.10"},{"path":"RouteStatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.11"},{"path":"RouteWeight","tag":"RouteWeight","type":"*variable","value":"~*req.12"},{"path":"RouteBlocker","tag":"RouteBlocker","type":"*variable","value":"~*req.13"},{"path":"RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.14"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.4"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.5"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Contexts","tag":"Contexts","type":"*variable","value":"~*req.2"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.3"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.4"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.5"},{"path":"StrategyParameters","tag":"StrategyParameters","type":"*variable","value":"~*req.6"},{"path":"ConnID","tag":"ConnID","type":"*variable","value":"~*req.7"},{"path":"ConnFilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.8"},{"path":"ConnWeight","tag":"ConnWeight","type":"*variable","value":"~*req.9"},{"path":"ConnBlocker","tag":"ConnBlocker","type":"*variable","value":"~*req.10"},{"path":"ConnParameters","tag":"ConnParameters","type":"*variable","value":"~*req.11"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.4"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"path":"RateID","tag":"RateID","type":"*variable","value":"~*req.7"},{"path":"RateFilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"path":"RateActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"path":"RateWeight","tag":"RateWeight","type":"*variable","value":"~*req.10"},{"path":"RateBlocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"path":"RateIntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"path":"RateFixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"path":"RateRecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"path":"RateUnit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"path":"RateIncrement","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"RateProfiles.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.4"},{"path":"TargetType","tag":"TargetType","type":"*variable","value":"~*req.5"},{"path":"TargetIDs","tag":"TargetIDs","type":"*variable","value":"~*req.6"},{"path":"ActionID","tag":"ActionID","type":"*variable","value":"~*req.7"},{"path":"ActionFilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.8"},{"path":"ActionBlocker","tag":"ActionBlocker","type":"*variable","value":"~*req.9"},{"path":"ActionTTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"path":"ActionType","tag":"ActionType","type":"*variable","value":"~*req.11"},{"path":"ActionOpts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"path":"ActionPath","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"path":"ActionValue","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"ActionProfiles.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"BalanceID","tag":"BalanceID","type":"*variable","value":"~*req.4"},{"path":"BalanceFilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.5"},{"path":"BalanceWeight","tag":"BalanceWeight","type":"*variable","value":"~*req.6"},{"path":"BalanceBlocker","tag":"BalanceBlocker","type":"*variable","value":"~*req.7"},{"path":"BalanceType","tag":"BalanceType","type":"*variable","value":"~*req.8"},{"path":"BalanceOpts","tag":"BalanceOpts","type":"*variable","value":"~*req.9"},{"path":"BalanceCostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.10"},{"path":"BalanceAttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.11"},{"path":"BalanceRateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.12"},{"path":"BalanceUnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.13"},{"path":"BalanceUnits","tag":"BalanceUnits","type":"*variable","value":"~*req.14"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.15"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"dry_run":false,"enabled":false,"field_separator":",","id":"*default","lock_filename":".cgr.lck","run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}],"migrator":{"out_datadb_encoding":"msgpack","out_datadb_host":"127.0.0.1","out_datadb_name":"10","out_datadb_opts":{"redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"out_datadb_password":"","out_datadb_port":"6379","out_datadb_type":"redis","out_datadb_user":"cgrates","out_stordb_host":"127.0.0.1","out_stordb_name":"cgrates","out_stordb_opts":{},"out_stordb_password":"","out_stordb_port":"3306","out_stordb_type":"mysql","out_stordb_user":"cgrates","users_filters":[]},"radius_agent":{"client_dictionaries":{"*default":"/usr/share/cgrates/radius/dict/"},"client_secrets":{"*default":"CGRateS.org"},"enabled":false,"listen_acct":"127.0.0.1:1813","listen_auth":"127.0.0.1:1812","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"]},"rates":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"rate_indexed_selects":true,"rate_nested_fields":false,"rate_prefix_indexed_fields":[],"rate_suffix_indexed_fields":[],"suffix_indexed_fields":[],"verbosity":1000},"registrarc":{"dispatcher":{"enabled":false,"hosts":{},"refresh_interval":"5m0s","registrars_conns":[]},"rpc":{"enabled":false,"hosts":{},"refresh_interval":"5m0s","registrars_conns":[]}},"resources":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[],"thresholds_conns":[]},"routes":{"attributes_conns":[],"default_ratio":1,"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"rpc_conns":{"*bijson_localhost":{"conns":[{"address":"127.0.0.1:2014","transport":"*birpc_json"}],"poolSize":0,"strategy":"*first"},"*birpc_internal":{"conns":[{"address":"*birpc_internal","transport":""}],"poolSize":0,"strategy":"*first"},"*internal":{"conns":[{"address":"*internal","transport":""}],"poolSize":0,"strategy":"*first"},"*localhost":{"conns":[{"address":"127.0.0.1:2012","transport":"*json"}],"poolSize":0,"strategy":"*first"}},"sessions":{"actions_conns":[],"alterable_fields":[],"attributes_conns":[],"cdrs_conns":[],"channel_sync_interval":"0","chargers_conns":[],"client_protocol":1,"debit_interval":"0","default_usage":{"*any":"3h0m0s","*data":"1048576","*sms":"1","*voice":"3h0m0s"},"enabled":false,"listen_bigob":"","listen_bijson":"127.0.0.1:2014","min_dur_low_balance":"0","replication_conns":[],"resources_conns":[],"routes_conns":[],"session_indexes":[],"session_ttl":"0","stats_conns":[],"stir":{"allowed_attest":["*any"],"default_attest":"A","payload_maxduration":"-1","privatekey_path":"","publickey_path":""},"store_session_costs":false,"terminate_attempts":5,"thresholds_conns":[]},"sip_agent":{"enabled":false,"listen":"127.0.0.1:5060","listen_net":"udp","request_processors":[],"retransmission_timer":"1s","sessions_conns":["*internal"],"timezone":""},"stats":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"store_interval":"","store_uncompressed_limit":0,"suffix_indexed_fields":[],"thresholds_conns":[]},"stor_db":{"db_host":"127.0.0.1","db_name":"cgrates","db_password":"","db_port":3306,"db_type":"*mysql","db_user":"cgrates","items":{"*cdrs":{"remote":false,"replicate":false},"*session_costs":{"remote":false,"replicate":false},"*tp_accounts":{"remote":false,"replicate":false},"*tp_action_profiles":{"remote":false,"replicate":false},"*tp_attributes":{"remote":false,"replicate":false},"*tp_chargers":{"remote":false,"replicate":false},"*tp_dispatcher_hosts":{"remote":false,"replicate":false},"*tp_dispatcher_profiles":{"remote":false,"replicate":false},"*tp_filters":{"remote":false,"replicate":false},"*tp_rate_profiles":{"remote":false,"replicate":false},"*tp_resources":{"remote":false,"replicate":false},"*tp_routes":{"remote":false,"replicate":false},"*tp_stats":{"remote":false,"replicate":false},"*tp_thresholds":{"remote":false,"replicate":false},"*versions":{"remote":false,"replicate":false}},"opts":{"mongoQueryTimeout":"10s","mysqlLocation":"Local","sqlConnMaxLifetime":0,"sqlMaxIdleConns":10,"sqlMaxOpenConns":100,"sslMode":"disable"},"prefix_indexed_fields":[],"remote_conns":null,"replication_conns":null,"string_indexed_fields":[]},"suretax":{"bill_to_number":"","business_unit":"","client_number":"","client_tracking":"~*req.CGRID","customer_number":"~*req.Subject","include_local_cost":false,"orig_number":"~*req.Subject","p2pplus4":"","p2pzipcode":"","plus4":"","regulatory_code":"03","response_group":"03","response_type":"D4","return_file_code":"0","sales_type_code":"R","tax_exemption_code_list":"","tax_included":"0","tax_situs_rule":"04","term_number":"~*req.Destination","timezone":"UTC","trans_type_code":"010101","unit_type":"00","units":"1","url":"","validation_key":"","zipcode":""},"templates":{"*asr":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"}],"*cca":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"path":"*rep.Result-Code","tag":"ResultCode","type":"*constant","value":"2001"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"},{"mandatory":true,"path":"*rep.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"mandatory":true,"path":"*rep.CC-Request-Type","tag":"CCRequestType","type":"*variable","value":"~*req.CC-Request-Type"},{"mandatory":true,"path":"*rep.CC-Request-Number","tag":"CCRequestNumber","type":"*variable","value":"~*req.CC-Request-Number"}],"*cdrLog":[{"mandatory":true,"path":"*cdr.ToR","tag":"ToR","type":"*variable","value":"~*req.BalanceType"},{"mandatory":true,"path":"*cdr.OriginHost","tag":"OriginHost","type":"*constant","value":"127.0.0.1"},{"mandatory":true,"path":"*cdr.RequestType","tag":"RequestType","type":"*constant","value":"*none"},{"mandatory":true,"path":"*cdr.Tenant","tag":"Tenant","type":"*variable","value":"~*req.Tenant"},{"mandatory":true,"path":"*cdr.Account","tag":"Account","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Subject","tag":"Subject","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Cost","tag":"Cost","type":"*variable","value":"~*req.Cost"},{"mandatory":true,"path":"*cdr.Source","tag":"Source","type":"*constant","value":"*cdrLog"},{"mandatory":true,"path":"*cdr.Usage","tag":"Usage","type":"*constant","value":"1"},{"mandatory":true,"path":"*cdr.RunID","tag":"RunID","type":"*variable","value":"~*req.ActionType"},{"mandatory":true,"path":"*cdr.SetupTime","tag":"SetupTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.AnswerTime","tag":"AnswerTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.PreRated","tag":"PreRated","type":"*constant","value":"true"}],"*err":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"}],"*errSip":[{"mandatory":true,"path":"*rep.Request","tag":"Request","type":"*constant","value":"SIP/2.0 500 Internal Server Error"}],"*rar":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"path":"*diamreq.Re-Auth-Request-Type","tag":"ReAuthRequestType","type":"*constant","value":"0"}]},"thresholds":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[]},"tls":{"ca_certificate":"","client_certificate":"","client_key":"","server_certificate":"","server_key":"","server_name":"","server_policy":4}}`
+ expected := `{"accounts":{"attributes_conns":[],"enabled":false,"indexed_selects":true,"max_iterations":1000,"max_usage":"259200000000000","nested_fields":false,"prefix_indexed_fields":[],"rates_conns":[],"suffix_indexed_fields":[],"thresholds_conns":[]},"actions":{"accounts_conns":[],"cdrs_conns":[],"ees_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"stats_conns":[],"suffix_indexed_fields":[],"tenants":[],"thresholds_conns":[]},"admins":{"actions_conns":[],"attributes_conns":[],"caches_conns":["*internal"],"ees_conns":[],"enabled":false},"analyzers":{"cleanup_interval":"1h0m0s","db_path":"/var/spool/cgrates/analyzers","enabled":false,"index_type":"*scorch","ttl":"24h0m0s"},"apiban":{"enabled":false,"keys":[]},"asterisk_agent":{"asterisk_conns":[{"address":"127.0.0.1:8088","alias":"","connect_attempts":3,"password":"CGRateS.org","reconnects":5,"user":"cgrates"}],"create_cdr":false,"enabled":false,"sessions_conns":["*birpc_internal"]},"attributes":{"admins_conns":[],"any_context":true,"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"process_runs":1,"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"caches":{"partitions":{"*account_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*apiban":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2m0s"},"*attribute_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*attribute_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*caps_events":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*cdr_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10m0s"},"*cdrs":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*charger_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*charger_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*closed_sessions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*diameter_messages":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*dispatcher_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_loads":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatcher_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*dispatchers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*event_charges":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"10s"},"*event_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*load_ids":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rate_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rate_profile_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*replication_hosts":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resource_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resource_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*reverse_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*route_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*route_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rpc_connections":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*rpc_responses":{"limit":0,"precache":false,"replicate":false,"static_ttl":false,"ttl":"2s"},"*session_costs":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*stat_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*statqueue_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*statqueues":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*stir":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*threshold_filter_indexes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*threshold_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_accounts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_action_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_attributes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_chargers":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_dispatcher_hosts":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_dispatcher_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_filters":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_rate_profiles":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_resources":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_routes":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_stats":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*tp_thresholds":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""},"*uch":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"3h0m0s"},"*versions":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":""}},"replication_conns":[]},"cdrs":{"actions_conns":[],"attributes_conns":[],"chargers_conns":[],"ees_conns":[],"enabled":false,"extra_fields":[],"online_cdr_exports":[],"session_cost_retries":5,"stats_conns":[],"store_cdrs":true,"thresholds_conns":[]},"chargers":{"attributes_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"config_db":{"db_host":"","db_name":"","db_password":"","db_port":0,"db_type":"*internal","db_user":"","items":{},"opts":{"query_timeout":"10s","redis_ca_certificate":"","redis_client_certificate":"","redis_client_key":"","redis_cluster":false,"redis_cluster_ondown_delay":"0","redis_cluster_sync":"5s","redis_sentinel":"","redis_tls":false},"remote_conn_id":"","remote_conns":null,"replication_cache":"","replication_conns":null,"replication_filtered":false},"configs":{"enabled":false,"root_dir":"/var/spool/cgrates/configs","url":"/configs/"},"cores":{"caps":0,"caps_stats_interval":"0","caps_strategy":"*busy","shutdown_timeout":"1s"},"data_db":{"db_host":"127.0.0.1","db_name":"10","db_password":"","db_port":6379,"db_type":"*redis","db_user":"cgrates","items":{"*accounts":{"remote":false,"replicate":false},"*action_profiles":{"remote":false,"replicate":false},"*actions":{"remote":false,"replicate":false},"*attribute_profiles":{"remote":false,"replicate":false},"*charger_profiles":{"remote":false,"replicate":false},"*dispatcher_hosts":{"remote":false,"replicate":false},"*dispatcher_profiles":{"remote":false,"replicate":false},"*filters":{"remote":false,"replicate":false},"*indexes":{"remote":false,"replicate":false},"*load_ids":{"remote":false,"replicate":false},"*rate_profiles":{"remote":false,"replicate":false},"*resource_profiles":{"remote":false,"replicate":false},"*resources":{"remote":false,"replicate":false},"*route_profiles":{"remote":false,"replicate":false},"*statqueue_profiles":{"remote":false,"replicate":false},"*statqueues":{"remote":false,"replicate":false},"*threshold_profiles":{"remote":false,"replicate":false},"*thresholds":{"remote":false,"replicate":false}},"opts":{"mongoQueryTimeout":"10s","redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"remote_conn_id":"","remote_conns":[],"replication_cache":"","replication_conns":[],"replication_filtered":false},"diameter_agent":{"asr_template":"","concurrent_requests":-1,"dictionaries_path":"/usr/share/cgrates/diameter/dict/","enabled":false,"forced_disconnect":"*none","listen":"127.0.0.1:3868","listen_net":"tcp","origin_host":"CGR-DA","origin_realm":"cgrates.org","product_name":"CGRateS","rar_template":"","request_processors":[],"sessions_conns":["*birpc_internal"],"synced_conn_requests":false,"vendor_id":0},"dispatchers":{"any_subsystem":true,"attributes_conns":[],"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"suffix_indexed_fields":[]},"dns_agent":{"enabled":false,"listen":"127.0.0.1:2053","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"],"timezone":""},"ees":{"attributes_conns":[],"cache":{"*file_csv":{"limit":-1,"precache":false,"replicate":false,"static_ttl":false,"ttl":"5s"}},"enabled":false,"exporters":[{"attempts":1,"attribute_context":"","attribute_ids":[],"export_path":"/var/spool/cgrates/ees","fields":[],"filters":[],"flags":[],"id":"*default","opts":{},"synchronous":false,"tenant":"","timezone":"","type":"*none"}]},"ers":{"enabled":false,"partial_cache_action":"*none","partial_cache_ttl":"1s","partial_path":"","readers":[{"cache_dump_fields":[],"concurrent_requests":1024,"fields":[{"mandatory":true,"path":"*cgreq.ToR","tag":"ToR","type":"*variable","value":"~*req.2"},{"mandatory":true,"path":"*cgreq.OriginID","tag":"OriginID","type":"*variable","value":"~*req.3"},{"mandatory":true,"path":"*cgreq.RequestType","tag":"RequestType","type":"*variable","value":"~*req.4"},{"mandatory":true,"path":"*cgreq.Tenant","tag":"Tenant","type":"*variable","value":"~*req.6"},{"mandatory":true,"path":"*cgreq.Category","tag":"Category","type":"*variable","value":"~*req.7"},{"mandatory":true,"path":"*cgreq.Account","tag":"Account","type":"*variable","value":"~*req.8"},{"mandatory":true,"path":"*cgreq.Subject","tag":"Subject","type":"*variable","value":"~*req.9"},{"mandatory":true,"path":"*cgreq.Destination","tag":"Destination","type":"*variable","value":"~*req.10"},{"mandatory":true,"path":"*cgreq.SetupTime","tag":"SetupTime","type":"*variable","value":"~*req.11"},{"mandatory":true,"path":"*cgreq.AnswerTime","tag":"AnswerTime","type":"*variable","value":"~*req.12"},{"mandatory":true,"path":"*cgreq.Usage","tag":"Usage","type":"*variable","value":"~*req.13"}],"filters":[],"flags":[],"id":"*default","opts":{"csvFieldSeparator":",","csvHeaderDefineChar":":","csvRowLength":0,"partialOrderField":"~*req.AnswerTime","xmlRootPath":""},"partial_commit_fields":[],"processed_path":"/var/spool/cgrates/ers/out","run_delay":"0","source_path":"/var/spool/cgrates/ers/in","tenant":"","timezone":"","type":"*none"}],"sessions_conns":["*internal"]},"filters":{"admins_conns":[],"resources_conns":[],"stats_conns":[]},"freeswitch_agent":{"create_cdr":false,"empty_balance_ann_file":"","empty_balance_context":"","enabled":false,"event_socket_conns":[{"address":"127.0.0.1:8021","alias":"127.0.0.1:8021","password":"ClueCon","reconnects":5}],"extra_fields":[],"low_balance_ann_file":"","max_wait_connection":"2s","sessions_conns":["*birpc_internal"],"subscribe_park":true},"general":{"connect_attempts":5,"connect_timeout":"1s","dbdata_encoding":"*msgpack","default_caching":"*reload","default_category":"call","default_request_type":"*rated","default_tenant":"cgrates.org","default_timezone":"Local","digest_equal":":","digest_separator":",","failed_posts_dir":"/var/spool/cgrates/failed_posts","failed_posts_ttl":"5s","locking_timeout":"0","log_level":6,"logger":"*syslog","max_parallel_conns":100,"node_id":"ENGINE1","poster_attempts":3,"reconnects":-1,"reply_timeout":"2s","rounding_decimals":5,"rsr_separator":";","tpexport_dir":"/var/spool/cgrates/tpe"},"http":{"auth_users":{},"client_opts":{"dialFallbackDelay":"300ms","dialKeepAlive":"30s","dialTimeout":"30s","disableCompression":false,"disableKeepAlives":false,"expectContinueTimeout":"0","forceAttemptHttp2":true,"idleConnTimeout":"90s","maxConnsPerHost":0,"maxIdleConns":100,"maxIdleConnsPerHost":2,"responseHeaderTimeout":"0","skipTlsVerify":false,"tlsHandshakeTimeout":"10s"},"freeswitch_cdrs_url":"/freeswitch_json","http_cdrs":"/cdr_http","json_rpc_url":"/jsonrpc","registrars_url":"/registrar","use_basic_auth":false,"ws_url":"/ws"},"http_agent":[],"kamailio_agent":{"create_cdr":false,"enabled":false,"evapi_conns":[{"address":"127.0.0.1:8448","alias":"","reconnects":5}],"sessions_conns":["*birpc_internal"],"timezone":""},"listen":{"http":"127.0.0.1:2080","http_tls":"127.0.0.1:2280","rpc_gob":"127.0.0.1:2013","rpc_gob_tls":"127.0.0.1:2023","rpc_json":"127.0.0.1:2012","rpc_json_tls":"127.0.0.1:2022"},"loader":{"actions_conns":["*localhost"],"caches_conns":["*localhost"],"data_path":"./","disable_reverse":false,"field_separator":",","gapi_credentials":".gapi/credentials.json","gapi_token":".gapi/token.json","tpid":""},"loaders":[{"caches_conns":["*internal"],"data":[{"fields":[{"mandatory":true,"path":"Tenant","tag":"TenantID","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ProfileID","type":"*variable","value":"~*req.1"},{"path":"Contexts","tag":"Contexts","type":"*variable","value":"~*req.2"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.3"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.4"},{"path":"AttributeFilterIDs","tag":"AttributeFilterIDs","type":"*variable","value":"~*req.5"},{"path":"Path","tag":"Path","type":"*variable","value":"~*req.6"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.7"},{"path":"Value","tag":"Value","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"}],"file_name":"Attributes.csv","flags":null,"type":"*attributes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Type","tag":"Type","type":"*variable","value":"~*req.2"},{"path":"Element","tag":"Element","type":"*variable","value":"~*req.3"},{"path":"Values","tag":"Values","type":"*variable","value":"~*req.4"}],"file_name":"Filters.csv","flags":null,"type":"*filters"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"UsageTTL","tag":"TTL","type":"*variable","value":"~*req.4"},{"path":"Limit","tag":"Limit","type":"*variable","value":"~*req.5"},{"path":"AllocationMessage","tag":"AllocationMessage","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.8"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.9"}],"file_name":"Resources.csv","flags":null,"type":"*resources"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"QueueLength","tag":"QueueLength","type":"*variable","value":"~*req.4"},{"path":"TTL","tag":"TTL","type":"*variable","value":"~*req.5"},{"path":"MinItems","tag":"MinItems","type":"*variable","value":"~*req.6"},{"path":"MetricIDs","tag":"MetricIDs","type":"*variable","value":"~*req.7"},{"path":"MetricFilterIDs","tag":"MetricFilterIDs","type":"*variable","value":"~*req.8"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.9"},{"path":"Stored","tag":"Stored","type":"*variable","value":"~*req.10"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.11"}],"file_name":"Stats.csv","flags":null,"type":"*stats"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"MaxHits","tag":"MaxHits","type":"*variable","value":"~*req.4"},{"path":"MinHits","tag":"MinHits","type":"*variable","value":"~*req.5"},{"path":"MinSleep","tag":"MinSleep","type":"*variable","value":"~*req.6"},{"path":"Blocker","tag":"Blocker","type":"*variable","value":"~*req.7"},{"path":"ActionIDs","tag":"ActionIDs","type":"*variable","value":"~*req.8"},{"path":"Async","tag":"Async","type":"*variable","value":"~*req.9"}],"file_name":"Thresholds.csv","flags":null,"type":"*thresholds"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Sorting","tag":"Sorting","type":"*variable","value":"~*req.4"},{"path":"SortingParameters","tag":"SortingParameters","type":"*variable","value":"~*req.5"},{"path":"RouteID","tag":"RouteID","type":"*variable","value":"~*req.6"},{"path":"RouteFilterIDs","tag":"RouteFilterIDs","type":"*variable","value":"~*req.7"},{"path":"RouteAccountIDs","tag":"RouteAccountIDs","type":"*variable","value":"~*req.8"},{"path":"RouteRatingPlanIDs","tag":"RouteRatingPlanIDs","type":"*variable","value":"~*req.9"},{"path":"RouteResourceIDs","tag":"RouteResourceIDs","type":"*variable","value":"~*req.10"},{"path":"RouteStatIDs","tag":"RouteStatIDs","type":"*variable","value":"~*req.11"},{"path":"RouteWeight","tag":"RouteWeight","type":"*variable","value":"~*req.12"},{"path":"RouteBlocker","tag":"RouteBlocker","type":"*variable","value":"~*req.13"},{"path":"RouteParameters","tag":"RouteParameters","type":"*variable","value":"~*req.14"}],"file_name":"Routes.csv","flags":null,"type":"*routes"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"RunID","tag":"RunID","type":"*variable","value":"~*req.4"},{"path":"AttributeIDs","tag":"AttributeIDs","type":"*variable","value":"~*req.5"}],"file_name":"Chargers.csv","flags":null,"type":"*chargers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Contexts","tag":"Contexts","type":"*variable","value":"~*req.2"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.3"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.4"},{"path":"Strategy","tag":"Strategy","type":"*variable","value":"~*req.5"},{"path":"StrategyParameters","tag":"StrategyParameters","type":"*variable","value":"~*req.6"},{"path":"ConnID","tag":"ConnID","type":"*variable","value":"~*req.7"},{"path":"ConnFilterIDs","tag":"ConnFilterIDs","type":"*variable","value":"~*req.8"},{"path":"ConnWeight","tag":"ConnWeight","type":"*variable","value":"~*req.9"},{"path":"ConnBlocker","tag":"ConnBlocker","type":"*variable","value":"~*req.10"},{"path":"ConnParameters","tag":"ConnParameters","type":"*variable","value":"~*req.11"}],"file_name":"DispatcherProfiles.csv","flags":null,"type":"*dispatchers"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"Address","tag":"Address","type":"*variable","value":"~*req.2"},{"path":"Transport","tag":"Transport","type":"*variable","value":"~*req.3"},{"path":"TLS","tag":"TLS","type":"*variable","value":"~*req.4"}],"file_name":"DispatcherHosts.csv","flags":null,"type":"*dispatcher_hosts"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"MinCost","tag":"MinCost","type":"*variable","value":"~*req.4"},{"path":"MaxCost","tag":"MaxCost","type":"*variable","value":"~*req.5"},{"path":"MaxCostStrategy","tag":"MaxCostStrategy","type":"*variable","value":"~*req.6"},{"path":"RateID","tag":"RateID","type":"*variable","value":"~*req.7"},{"path":"RateFilterIDs","tag":"RateFilterIDs","type":"*variable","value":"~*req.8"},{"path":"RateActivationTimes","tag":"RateActivationTimes","type":"*variable","value":"~*req.9"},{"path":"RateWeight","tag":"RateWeight","type":"*variable","value":"~*req.10"},{"path":"RateBlocker","tag":"RateBlocker","type":"*variable","value":"~*req.11"},{"path":"RateIntervalStart","tag":"RateIntervalStart","type":"*variable","value":"~*req.12"},{"path":"RateFixedFee","tag":"RateFixedFee","type":"*variable","value":"~*req.13"},{"path":"RateRecurrentFee","tag":"RateRecurrentFee","type":"*variable","value":"~*req.14"},{"path":"RateUnit","tag":"RateUnit","type":"*variable","value":"~*req.15"},{"path":"RateIncrement","tag":"RateIncrement","type":"*variable","value":"~*req.16"}],"file_name":"RateProfiles.csv","flags":null,"type":"*rate_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"Schedule","tag":"Schedule","type":"*variable","value":"~*req.4"},{"path":"TargetType","tag":"TargetType","type":"*variable","value":"~*req.5"},{"path":"TargetIDs","tag":"TargetIDs","type":"*variable","value":"~*req.6"},{"path":"ActionID","tag":"ActionID","type":"*variable","value":"~*req.7"},{"path":"ActionFilterIDs","tag":"ActionFilterIDs","type":"*variable","value":"~*req.8"},{"path":"ActionBlocker","tag":"ActionBlocker","type":"*variable","value":"~*req.9"},{"path":"ActionTTL","tag":"ActionTTL","type":"*variable","value":"~*req.10"},{"path":"ActionType","tag":"ActionType","type":"*variable","value":"~*req.11"},{"path":"ActionOpts","tag":"ActionOpts","type":"*variable","value":"~*req.12"},{"path":"ActionPath","tag":"ActionPath","type":"*variable","value":"~*req.13"},{"path":"ActionValue","tag":"ActionValue","type":"*variable","value":"~*req.14"}],"file_name":"ActionProfiles.csv","flags":null,"type":"*action_profiles"},{"fields":[{"mandatory":true,"path":"Tenant","tag":"Tenant","type":"*variable","value":"~*req.0"},{"mandatory":true,"path":"ID","tag":"ID","type":"*variable","value":"~*req.1"},{"path":"FilterIDs","tag":"FilterIDs","type":"*variable","value":"~*req.2"},{"path":"Weight","tag":"Weight","type":"*variable","value":"~*req.3"},{"path":"BalanceID","tag":"BalanceID","type":"*variable","value":"~*req.4"},{"path":"BalanceFilterIDs","tag":"BalanceFilterIDs","type":"*variable","value":"~*req.5"},{"path":"BalanceWeight","tag":"BalanceWeight","type":"*variable","value":"~*req.6"},{"path":"BalanceBlocker","tag":"BalanceBlocker","type":"*variable","value":"~*req.7"},{"path":"BalanceType","tag":"BalanceType","type":"*variable","value":"~*req.8"},{"path":"BalanceOpts","tag":"BalanceOpts","type":"*variable","value":"~*req.9"},{"path":"BalanceCostIncrements","tag":"BalanceCostIncrements","type":"*variable","value":"~*req.10"},{"path":"BalanceAttributeIDs","tag":"BalanceAttributeIDs","type":"*variable","value":"~*req.11"},{"path":"BalanceRateProfileIDs","tag":"BalanceRateProfileIDs","type":"*variable","value":"~*req.12"},{"path":"BalanceUnitFactors","tag":"BalanceUnitFactors","type":"*variable","value":"~*req.13"},{"path":"BalanceUnits","tag":"BalanceUnits","type":"*variable","value":"~*req.14"},{"path":"ThresholdIDs","tag":"ThresholdIDs","type":"*variable","value":"~*req.15"}],"file_name":"Accounts.csv","flags":null,"type":"*accounts"}],"dry_run":false,"enabled":false,"field_separator":",","id":"*default","lock_filename":".cgr.lck","run_delay":"0","tenant":"","tp_in_dir":"/var/spool/cgrates/loader/in","tp_out_dir":"/var/spool/cgrates/loader/out"}],"migrator":{"out_datadb_encoding":"msgpack","out_datadb_host":"127.0.0.1","out_datadb_name":"10","out_datadb_opts":{"redisCACertificate":"","redisClientCertificate":"","redisClientKey":"","redisCluster":false,"redisClusterOndownDelay":"0","redisClusterSync":"5s","redisSentinel":"","redisTLS":false},"out_datadb_password":"","out_datadb_port":"6379","out_datadb_type":"redis","out_datadb_user":"cgrates","out_stordb_host":"127.0.0.1","out_stordb_name":"cgrates","out_stordb_opts":{},"out_stordb_password":"","out_stordb_port":"3306","out_stordb_type":"mysql","out_stordb_user":"cgrates","users_filters":[]},"radius_agent":{"client_dictionaries":{"*default":"/usr/share/cgrates/radius/dict/"},"client_secrets":{"*default":"CGRateS.org"},"enabled":false,"listen_acct":"127.0.0.1:1813","listen_auth":"127.0.0.1:1812","listen_net":"udp","request_processors":[],"sessions_conns":["*internal"]},"rates":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"rate_indexed_selects":true,"rate_nested_fields":false,"rate_prefix_indexed_fields":[],"rate_suffix_indexed_fields":[],"suffix_indexed_fields":[],"verbosity":1000},"registrarc":{"dispatcher":{"enabled":false,"hosts":{},"refresh_interval":"5m0s","registrars_conns":[]},"rpc":{"enabled":false,"hosts":{},"refresh_interval":"5m0s","registrars_conns":[]}},"resources":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[],"thresholds_conns":[]},"routes":{"attributes_conns":[],"default_ratio":1,"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"resources_conns":[],"stats_conns":[],"suffix_indexed_fields":[]},"rpc_conns":{"*bijson_localhost":{"conns":[{"address":"127.0.0.1:2014","transport":"*birpc_json"}],"poolSize":0,"strategy":"*first"},"*birpc_internal":{"conns":[{"address":"*birpc_internal","transport":""}],"poolSize":0,"strategy":"*first"},"*internal":{"conns":[{"address":"*internal","transport":""}],"poolSize":0,"strategy":"*first"},"*localhost":{"conns":[{"address":"127.0.0.1:2012","transport":"*json"}],"poolSize":0,"strategy":"*first"}},"sessions":{"actions_conns":[],"alterable_fields":[],"attributes_conns":[],"cdrs_conns":[],"channel_sync_interval":"0","chargers_conns":[],"client_protocol":1,"debit_interval":"0","default_usage":{"*any":"3h0m0s","*data":"1048576","*sms":"1","*voice":"3h0m0s"},"enabled":false,"listen_bigob":"","listen_bijson":"127.0.0.1:2014","min_dur_low_balance":"0","replication_conns":[],"resources_conns":[],"routes_conns":[],"session_indexes":[],"session_ttl":"0","stats_conns":[],"stir":{"allowed_attest":["*any"],"default_attest":"A","payload_maxduration":"-1","privatekey_path":"","publickey_path":""},"store_session_costs":false,"terminate_attempts":5,"thresholds_conns":[]},"sip_agent":{"enabled":false,"listen":"127.0.0.1:5060","listen_net":"udp","request_processors":[],"retransmission_timer":"1s","sessions_conns":["*internal"],"timezone":""},"stats":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"store_interval":"","store_uncompressed_limit":0,"suffix_indexed_fields":[],"thresholds_conns":[]},"stor_db":{"db_host":"127.0.0.1","db_name":"cgrates","db_password":"","db_port":3306,"db_type":"*mysql","db_user":"cgrates","items":{"*cdrs":{"remote":false,"replicate":false},"*session_costs":{"remote":false,"replicate":false},"*tp_accounts":{"remote":false,"replicate":false},"*tp_action_profiles":{"remote":false,"replicate":false},"*tp_attributes":{"remote":false,"replicate":false},"*tp_chargers":{"remote":false,"replicate":false},"*tp_dispatcher_hosts":{"remote":false,"replicate":false},"*tp_dispatcher_profiles":{"remote":false,"replicate":false},"*tp_filters":{"remote":false,"replicate":false},"*tp_rate_profiles":{"remote":false,"replicate":false},"*tp_resources":{"remote":false,"replicate":false},"*tp_routes":{"remote":false,"replicate":false},"*tp_stats":{"remote":false,"replicate":false},"*tp_thresholds":{"remote":false,"replicate":false},"*versions":{"remote":false,"replicate":false}},"opts":{"mongoQueryTimeout":"10s","mysqlLocation":"Local","sqlConnMaxLifetime":0,"sqlMaxIdleConns":10,"sqlMaxOpenConns":100,"sslMode":"disable"},"prefix_indexed_fields":[],"remote_conns":null,"replication_conns":null,"string_indexed_fields":[]},"suretax":{"bill_to_number":"","business_unit":"","client_number":"","client_tracking":"~*req.CGRID","customer_number":"~*req.Subject","include_local_cost":false,"orig_number":"~*req.Subject","p2pplus4":"","p2pzipcode":"","plus4":"","regulatory_code":"03","response_group":"03","response_type":"D4","return_file_code":"0","sales_type_code":"R","tax_exemption_code_list":"","tax_included":"0","tax_situs_rule":"04","term_number":"~*req.Destination","timezone":"UTC","trans_type_code":"010101","unit_type":"00","units":"1","url":"","validation_key":"","zipcode":""},"templates":{"*asr":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"}],"*cca":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"path":"*rep.Result-Code","tag":"ResultCode","type":"*constant","value":"2001"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"},{"mandatory":true,"path":"*rep.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"mandatory":true,"path":"*rep.CC-Request-Type","tag":"CCRequestType","type":"*variable","value":"~*req.CC-Request-Type"},{"mandatory":true,"path":"*rep.CC-Request-Number","tag":"CCRequestNumber","type":"*variable","value":"~*req.CC-Request-Number"}],"*cdrLog":[{"mandatory":true,"path":"*cdr.ToR","tag":"ToR","type":"*variable","value":"~*req.BalanceType"},{"mandatory":true,"path":"*cdr.OriginHost","tag":"OriginHost","type":"*constant","value":"127.0.0.1"},{"mandatory":true,"path":"*cdr.RequestType","tag":"RequestType","type":"*constant","value":"*none"},{"mandatory":true,"path":"*cdr.Tenant","tag":"Tenant","type":"*variable","value":"~*req.Tenant"},{"mandatory":true,"path":"*cdr.Account","tag":"Account","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Subject","tag":"Subject","type":"*variable","value":"~*req.Account"},{"mandatory":true,"path":"*cdr.Cost","tag":"Cost","type":"*variable","value":"~*req.Cost"},{"mandatory":true,"path":"*cdr.Source","tag":"Source","type":"*constant","value":"*cdrLog"},{"mandatory":true,"path":"*cdr.Usage","tag":"Usage","type":"*constant","value":"1"},{"mandatory":true,"path":"*cdr.RunID","tag":"RunID","type":"*variable","value":"~*req.ActionType"},{"mandatory":true,"path":"*cdr.SetupTime","tag":"SetupTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.AnswerTime","tag":"AnswerTime","type":"*constant","value":"*now"},{"mandatory":true,"path":"*cdr.PreRated","tag":"PreRated","type":"*constant","value":"true"}],"*err":[{"mandatory":true,"path":"*rep.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*rep.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*vars.OriginHost"},{"mandatory":true,"path":"*rep.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*vars.OriginRealm"}],"*errSip":[{"mandatory":true,"path":"*rep.Request","tag":"Request","type":"*constant","value":"SIP/2.0 500 Internal Server Error"}],"*rar":[{"mandatory":true,"path":"*diamreq.Session-Id","tag":"SessionId","type":"*variable","value":"~*req.Session-Id"},{"mandatory":true,"path":"*diamreq.Origin-Host","tag":"OriginHost","type":"*variable","value":"~*req.Destination-Host"},{"mandatory":true,"path":"*diamreq.Origin-Realm","tag":"OriginRealm","type":"*variable","value":"~*req.Destination-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Realm","tag":"DestinationRealm","type":"*variable","value":"~*req.Origin-Realm"},{"mandatory":true,"path":"*diamreq.Destination-Host","tag":"DestinationHost","type":"*variable","value":"~*req.Origin-Host"},{"mandatory":true,"path":"*diamreq.Auth-Application-Id","tag":"AuthApplicationId","type":"*variable","value":"~*vars.*appid"},{"path":"*diamreq.Re-Auth-Request-Type","tag":"ReAuthRequestType","type":"*constant","value":"0"}]},"thresholds":{"enabled":false,"indexed_selects":true,"nested_fields":false,"prefix_indexed_fields":[],"store_interval":"","suffix_indexed_fields":[]},"tls":{"ca_certificate":"","client_certificate":"","client_key":"","server_certificate":"","server_key":"","server_name":"","server_policy":4}}`
cgrCfg, err := NewCGRConfigFromJSONStringWithDefaults(cfgJSON)
if err != nil {
t.Fatal(err)
diff --git a/data/conf/samples/attributesindexes_mongo/cgrates.json b/data/conf/samples/attributesindexes_mongo/cgrates.json
new file mode 100644
index 000000000..da7746f8c
--- /dev/null
+++ b/data/conf/samples/attributesindexes_mongo/cgrates.json
@@ -0,0 +1,22 @@
+{
+ // CGRateS Configuration file
+ // used in general_tests/attributes_filters_index_it_test.go
+ "general": {
+ "log_level": 7,
+ },
+
+ "stor_db": {
+ "db_password": "CGRateS.org"
+ },
+
+ "admins": {
+ "enabled": true,
+ },
+
+ "attributes": {
+ "enabled": true,
+ "string_indexed_fields": [],
+ "prefix_indexed_fields": ["*req.Subject"],
+ },
+
+ }
\ No newline at end of file
diff --git a/data/conf/samples/attributesindexes_mysql/cgrates.json b/data/conf/samples/attributesindexes_mysql/cgrates.json
new file mode 100644
index 000000000..14904ed77
--- /dev/null
+++ b/data/conf/samples/attributesindexes_mysql/cgrates.json
@@ -0,0 +1,33 @@
+{
+ // CGRateS Configuration file
+ // used in general_tests/attributes_filters_index_it_test.go
+ "general": {
+ "log_level": 7,
+ },
+
+
+ "data_db": {
+ "db_type": "mongo",
+ "db_name": "10",
+ "db_port": 27017,
+ },
+
+
+ "stor_db": {
+ "db_type": "mongo",
+ "db_name": "cgrates",
+ "db_port": 27017,
+ },
+
+
+ "admins": {
+ "enabled": true,
+ },
+
+ "attributes": {
+ "enabled": true,
+ "string_indexed_fields": [],
+ "prefix_indexed_fields": ["*req.Subject"],
+ },
+
+ }
\ No newline at end of file
diff --git a/dispatchers/dispatchers.go b/dispatchers/dispatchers.go
index 9cb7173cd..21408e479 100644
--- a/dispatchers/dispatchers.go
+++ b/dispatchers/dispatchers.go
@@ -145,7 +145,7 @@ func (dS *DispatcherService) dispatcherProfileForEvent(tnt string, ev *utils.CGR
err = nil // make sure we ignore the error from *any subsystem matching
}
for prflID := range prflIDs {
- prfl, err := dS.dm.GetDispatcherProfile(tnt, prflID, true, true, utils.NonTransactional)
+ prfl, err := dS.dm.GetDispatcherProfile(context.TODO(), tnt, prflID, true, true, utils.NonTransactional)
if err != nil {
if err != utils.ErrNotFound {
return nil, err
diff --git a/dispatchers/dispatchers_test.go b/dispatchers/dispatchers_test.go
index d33a2c24e..49b60d141 100644
--- a/dispatchers/dispatchers_test.go
+++ b/dispatchers/dispatchers_test.go
@@ -51,7 +51,7 @@ func TestDispatcherServiceDispatcherProfileForEventGetDispatcherProfileNF(t *tes
Weight: 0,
Hosts: nil,
}
- err := dm.SetDispatcherProfile(dsp, false)
+ err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
if err == nil {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", utils.ErrNotImplemented, err)
}
@@ -502,7 +502,7 @@ func TestDispatcherServiceDispatcherProfileForEventErrNil(t *testing.T) {
Weight: 0,
Hosts: nil,
}
- err := dm.SetDispatcherProfile(dsp, false)
+ err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
if err != nil {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
}
@@ -545,7 +545,7 @@ func TestDispatcherV1GetProfileForEventReturn(t *testing.T) {
Weight: 0,
Hosts: nil,
}
- err := dm.SetDispatcherProfile(dsp, false)
+ err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
if err != nil {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
}
@@ -594,7 +594,7 @@ func TestDispatcherServiceDispatcherProfileForEventErrNotFound(t *testing.T) {
Weight: 0,
Hosts: nil,
}
- err := dm.SetDispatcherProfile(dsp, false)
+ err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
if err != nil {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
}
@@ -637,7 +637,7 @@ func TestDispatcherServiceDispatcherProfileForEventErrNotFound2(t *testing.T) {
Weight: 0,
Hosts: nil,
}
- err := dm.SetDispatcherProfile(dsp, false)
+ err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
if err != nil {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
}
@@ -680,7 +680,7 @@ func TestDispatcherServiceDispatcherProfileForEventErrNotFoundFilter(t *testing.
Weight: 0,
Hosts: nil,
}
- err := dm.SetDispatcherProfile(dsp, false)
+ err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
if err != nil {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
}
@@ -723,7 +723,7 @@ func TestDispatcherServiceDispatchDspErr(t *testing.T) {
Weight: 0,
Hosts: nil,
}
- err := dm.SetDispatcherProfile(dsp, false)
+ err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
if err != nil {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
}
@@ -777,7 +777,7 @@ func TestDispatcherServiceDispatchDspErrHostNotFound(t *testing.T) {
engine.Cache = newCache
engine.Cache.Set(ctx, utils.CacheDispatchers, dsp.TenantID(), value, nil, true, utils.EmptyString)
- err := dm.SetDispatcherProfile(dsp, false)
+ err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
if err != nil {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
}
@@ -821,7 +821,7 @@ func TestDispatcherServiceDispatcherProfileForEventFoundFilter(t *testing.T) {
Weight: 0,
Hosts: nil,
}
- err := dm.SetDispatcherProfile(dsp, false)
+ err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
if err != nil {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
}
@@ -905,7 +905,7 @@ func TestDispatcherServiceDispatcherProfileForEventGetDispatcherError(t *testing
Weight: 0,
Hosts: nil,
}
- err := dm.SetDispatcherProfile(dsp, false)
+ err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
if err != nil {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
}
@@ -958,7 +958,7 @@ func TestDispatcherServiceDispatchDspErrHostNotFound2(t *testing.T) {
engine.Cache = newCache
engine.Cache.Set(ctx, utils.CacheDispatchers, dsp.TenantID(), value, nil, true, utils.EmptyString)
- err := dm.SetDispatcherProfile(dsp, false)
+ err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
if err != nil {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
}
@@ -1020,7 +1020,7 @@ func TestDispatcherServiceDispatchDspErrHostNotFound3(t *testing.T) {
newCache := engine.NewCacheS(cfg, dm, nil)
engine.Cache = newCache
- err := dm.SetDispatcherProfile(dsp, false)
+ err := dm.SetDispatcherProfile(context.TODO(), dsp, false)
if err != nil {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
}
diff --git a/engine/datadbmock.go b/engine/datadbmock.go
index 1c23e1803..dddefb931 100644
--- a/engine/datadbmock.go
+++ b/engine/datadbmock.go
@@ -230,15 +230,15 @@ func (dbM *DataDBMock) RemoveChargerProfileDrv(string, string) error {
return utils.ErrNotImplemented
}
-func (dbM *DataDBMock) GetDispatcherProfileDrv(string, string) (*DispatcherProfile, error) {
+func (dbM *DataDBMock) GetDispatcherProfileDrv(*context.Context, string, string) (*DispatcherProfile, error) {
return nil, utils.ErrNotImplemented
}
-func (dbM *DataDBMock) SetDispatcherProfileDrv(*DispatcherProfile) error {
+func (dbM *DataDBMock) SetDispatcherProfileDrv(*context.Context, *DispatcherProfile) error {
return utils.ErrNotImplemented
}
-func (dbM *DataDBMock) RemoveDispatcherProfileDrv(string, string) error {
+func (dbM *DataDBMock) RemoveDispatcherProfileDrv(*context.Context, string, string) error {
return utils.ErrNotImplemented
}
diff --git a/engine/datamanager.go b/engine/datamanager.go
index 252c9f246..3540fb083 100644
--- a/engine/datamanager.go
+++ b/engine/datamanager.go
@@ -174,7 +174,7 @@ func (dm *DataManager) CacheDataFromDB(ctx *context.Context, prfx string, ids []
_, err = dm.GetChargerProfile(tntID.Tenant, tntID.ID, false, true, utils.NonTransactional)
case utils.DispatcherProfilePrefix:
tntID := utils.NewTenantID(dataID)
- _, err = dm.GetDispatcherProfile(tntID.Tenant, tntID.ID, false, true, utils.NonTransactional)
+ _, err = dm.GetDispatcherProfile(ctx, tntID.Tenant, tntID.ID, false, true, utils.NonTransactional)
case utils.DispatcherHostPrefix:
tntID := utils.NewTenantID(dataID)
_, err = dm.GetDispatcherHost(tntID.Tenant, tntID.ID, false, true, utils.NonTransactional)
@@ -1582,7 +1582,7 @@ func (dm *DataManager) RemoveChargerProfile(tenant, id string,
return
}
-func (dm *DataManager) GetDispatcherProfile(tenant, id string, cacheRead, cacheWrite bool,
+func (dm *DataManager) GetDispatcherProfile(ctx *context.Context, tenant, id string, cacheRead, cacheWrite bool,
transactionID string) (dpp *DispatcherProfile, err error) {
tntID := utils.ConcatenatedKey(tenant, id)
if cacheRead {
@@ -1597,10 +1597,10 @@ func (dm *DataManager) GetDispatcherProfile(tenant, id string, cacheRead, cacheW
err = utils.ErrNoDatabaseConn
return
}
- dpp, err = dm.dataDB.GetDispatcherProfileDrv(tenant, id)
+ dpp, err = dm.dataDB.GetDispatcherProfileDrv(ctx, tenant, id)
if err != nil {
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaDispatcherProfiles]; err == utils.ErrNotFound && itm.Remote {
- if err = dm.connMgr.Call(context.TODO(), config.CgrConfig().DataDbCfg().RmtConns,
+ if err = dm.connMgr.Call(ctx, config.CgrConfig().DataDbCfg().RmtConns,
utils.ReplicatorSv1GetDispatcherProfile,
&utils.TenantIDWithAPIOpts{
TenantID: &utils.TenantID{Tenant: tenant, ID: id},
@@ -1608,13 +1608,13 @@ func (dm *DataManager) GetDispatcherProfile(tenant, id string, cacheRead, cacheW
utils.FirstNonEmpty(config.CgrConfig().DataDbCfg().RmtConnID,
config.CgrConfig().GeneralCfg().NodeID)),
}, &dpp); err == nil {
- err = dm.dataDB.SetDispatcherProfileDrv(dpp)
+ err = dm.dataDB.SetDispatcherProfileDrv(ctx, dpp)
}
}
if err != nil {
err = utils.CastRPCErr(err)
if err == utils.ErrNotFound && cacheWrite && dm.dataDB.GetStorageType() != utils.Internal {
- if errCh := Cache.Set(context.TODO(), utils.CacheDispatcherProfiles, tntID, nil, nil,
+ if errCh := Cache.Set(ctx, utils.CacheDispatcherProfiles, tntID, nil, nil,
cacheCommit(transactionID), transactionID); errCh != nil {
return nil, errCh
}
@@ -1624,7 +1624,7 @@ func (dm *DataManager) GetDispatcherProfile(tenant, id string, cacheRead, cacheW
}
}
if cacheWrite {
- if errCh := Cache.Set(context.TODO(), utils.CacheDispatcherProfiles, tntID, dpp, nil,
+ if errCh := Cache.Set(ctx, utils.CacheDispatcherProfiles, tntID, dpp, nil,
cacheCommit(transactionID), transactionID); errCh != nil {
return nil, errCh
}
@@ -1632,22 +1632,22 @@ func (dm *DataManager) GetDispatcherProfile(tenant, id string, cacheRead, cacheW
return
}
-func (dm *DataManager) SetDispatcherProfile(dpp *DispatcherProfile, withIndex bool) (err error) {
+func (dm *DataManager) SetDispatcherProfile(ctx *context.Context, dpp *DispatcherProfile, withIndex bool) (err error) {
if dm == nil {
return utils.ErrNoDatabaseConn
}
if withIndex {
- if brokenReference := dm.checkFilters(context.TODO(), dpp.Tenant, dpp.FilterIDs); len(brokenReference) != 0 {
+ if brokenReference := dm.checkFilters(ctx, dpp.Tenant, dpp.FilterIDs); len(brokenReference) != 0 {
// if we get a broken filter do not set the profile
return fmt.Errorf("broken reference to filter: %+v for item with ID: %+v",
brokenReference, dpp.TenantID())
}
}
- oldDpp, err := dm.GetDispatcherProfile(dpp.Tenant, dpp.ID, true, false, utils.NonTransactional)
+ oldDpp, err := dm.GetDispatcherProfile(ctx, dpp.Tenant, dpp.ID, true, false, utils.NonTransactional)
if err != nil && err != utils.ErrNotFound {
return err
}
- if err = dm.DataDB().SetDispatcherProfileDrv(dpp); err != nil {
+ if err = dm.DataDB().SetDispatcherProfileDrv(ctx, dpp); err != nil {
return err
}
if withIndex {
@@ -1657,13 +1657,13 @@ func (dm *DataManager) SetDispatcherProfile(dpp *DispatcherProfile, withIndex bo
oldContexes = &oldDpp.Subsystems
oldFiltersIDs = &oldDpp.FilterIDs
}
- if err = updatedIndexesWithContexts(context.TODO(), dm, utils.CacheDispatcherFilterIndexes, dpp.Tenant, dpp.ID,
+ if err = updatedIndexesWithContexts(ctx, dm, utils.CacheDispatcherFilterIndexes, dpp.Tenant, dpp.ID,
oldContexes, oldFiltersIDs, dpp.Subsystems, dpp.FilterIDs); err != nil {
return
}
}
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaDispatcherProfiles]; itm.Replicate {
- err = replicate(context.TODO(), dm.connMgr, config.CgrConfig().DataDbCfg().RplConns,
+ err = replicate(ctx, dm.connMgr, config.CgrConfig().DataDbCfg().RplConns,
config.CgrConfig().DataDbCfg().RplFiltered,
utils.DispatcherProfilePrefix, dpp.TenantID(), // this are used to get the host IDs from cache
utils.ReplicatorSv1SetDispatcherProfile,
@@ -1675,34 +1675,34 @@ func (dm *DataManager) SetDispatcherProfile(dpp *DispatcherProfile, withIndex bo
return
}
-func (dm *DataManager) RemoveDispatcherProfile(tenant, id string,
+func (dm *DataManager) RemoveDispatcherProfile(ctx *context.Context, tenant, id string,
transactionID string, withIndex bool) (err error) {
if dm == nil {
return utils.ErrNoDatabaseConn
}
- oldDpp, err := dm.GetDispatcherProfile(tenant, id, true, false, utils.NonTransactional)
+ oldDpp, err := dm.GetDispatcherProfile(ctx, tenant, id, true, false, utils.NonTransactional)
if err != nil && err != utils.ErrNotFound {
return err
}
- if err = dm.DataDB().RemoveDispatcherProfileDrv(tenant, id); err != nil {
+ if err = dm.DataDB().RemoveDispatcherProfileDrv(ctx, tenant, id); err != nil {
return
}
if oldDpp == nil {
return utils.ErrNotFound
}
if withIndex {
- if err = removeIndexFiltersItem(context.TODO(), dm, utils.CacheDispatcherFilterIndexes, tenant, id, oldDpp.FilterIDs); err != nil {
+ if err = removeIndexFiltersItem(ctx, dm, utils.CacheDispatcherFilterIndexes, tenant, id, oldDpp.FilterIDs); err != nil {
return
}
- for _, ctx := range oldDpp.Subsystems {
- if err = removeItemFromFilterIndex(context.TODO(), dm, utils.CacheDispatcherFilterIndexes,
- tenant, ctx, id, oldDpp.FilterIDs); err != nil {
+ for _, sub := range oldDpp.Subsystems {
+ if err = removeItemFromFilterIndex(ctx, dm, utils.CacheDispatcherFilterIndexes,
+ tenant, sub, id, oldDpp.FilterIDs); err != nil {
return
}
}
}
if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaDispatcherProfiles]; itm.Replicate {
- replicate(context.TODO(), dm.connMgr, config.CgrConfig().DataDbCfg().RplConns,
+ replicate(ctx, dm.connMgr, config.CgrConfig().DataDbCfg().RplConns,
config.CgrConfig().DataDbCfg().RplFiltered,
utils.DispatcherProfilePrefix, utils.ConcatenatedKey(tenant, id), // this are used to get the host IDs from cache
utils.ReplicatorSv1RemoveDispatcherProfile,
diff --git a/engine/libindex.go b/engine/libindex.go
index 639a35a5d..21dd55930 100644
--- a/engine/libindex.go
+++ b/engine/libindex.go
@@ -511,7 +511,7 @@ func removeIndexFiltersItem(ctx *context.Context, dm *DataManager, idxItmType, t
// UpdateFilterIndex will update the indexes for the new Filter
// we do not care what is added
// exported for the migrator
-func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Filter) (err error) {
+func UpdateFilterIndex(apiCtx *context.Context, dm *DataManager, oldFlt, newFlt *Filter) (err error) {
if oldFlt == nil { // no filter before so no index to update
return // nothing to update
}
@@ -584,7 +584,7 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
defer guardian.Guardian.UnguardIDs(refID)
var rcvIndx map[string]utils.StringSet
// get all reverse indexes from DB
- if rcvIndx, err = dm.GetIndexes(ctx, utils.CacheReverseFilterIndexes, tntID,
+ if rcvIndx, err = dm.GetIndexes(apiCtx, utils.CacheReverseFilterIndexes, tntID,
utils.EmptyString, true, false); err != nil {
if err != utils.ErrNotFound {
return
@@ -598,12 +598,12 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
for idxItmType, indx := range rcvIndx {
switch idxItmType {
case utils.CacheThresholdFilterIndexes:
- if err = removeFilterIndexesForFilter(dm, idxItmType, newFlt.Tenant, // remove the indexes for the filter
+ if err = removeFilterIndexesForFilter(apiCtx, dm, idxItmType, newFlt.Tenant, // remove the indexes for the filter
removeIndexKeys, indx); err != nil {
return
}
idxSlice := indx.AsSlice()
- if _, err = ComputeIndexes(ctx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
+ if _, err = ComputeIndexes(apiCtx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
&idxSlice, utils.NonTransactional, func(tnt, id, ctx string) (*[]string, error) {
th, e := dm.GetThresholdProfile(tnt, id, true, false, utils.NonTransactional)
if e != nil {
@@ -618,12 +618,12 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
return utils.APIErrorHandler(err)
}
case utils.CacheStatFilterIndexes:
- if err = removeFilterIndexesForFilter(dm, idxItmType, newFlt.Tenant, // remove the indexes for the filter
+ if err = removeFilterIndexesForFilter(apiCtx, dm, idxItmType, newFlt.Tenant, // remove the indexes for the filter
removeIndexKeys, indx); err != nil {
return
}
idxSlice := indx.AsSlice()
- if _, err = ComputeIndexes(ctx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
+ if _, err = ComputeIndexes(apiCtx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
&idxSlice, utils.NonTransactional, func(tnt, id, ctx string) (*[]string, error) {
sq, e := dm.GetStatQueueProfile(tnt, id, true, false, utils.NonTransactional)
if e != nil {
@@ -638,12 +638,12 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
return utils.APIErrorHandler(err)
}
case utils.CacheResourceFilterIndexes:
- if err = removeFilterIndexesForFilter(dm, idxItmType, newFlt.Tenant, // remove the indexes for the filter
+ if err = removeFilterIndexesForFilter(apiCtx, dm, idxItmType, newFlt.Tenant, // remove the indexes for the filter
removeIndexKeys, indx); err != nil {
return
}
idxSlice := indx.AsSlice()
- if _, err = ComputeIndexes(ctx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
+ if _, err = ComputeIndexes(apiCtx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
&idxSlice, utils.NonTransactional, func(tnt, id, ctx string) (*[]string, error) {
rs, e := dm.GetResourceProfile(tnt, id, true, false, utils.NonTransactional)
if e != nil {
@@ -658,12 +658,12 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
return utils.APIErrorHandler(err)
}
case utils.CacheRouteFilterIndexes:
- if err = removeFilterIndexesForFilter(dm, idxItmType, newFlt.Tenant, // remove the indexes for the filter
+ if err = removeFilterIndexesForFilter(apiCtx, dm, idxItmType, newFlt.Tenant, // remove the indexes for the filter
removeIndexKeys, indx); err != nil {
return
}
idxSlice := indx.AsSlice()
- if _, err = ComputeIndexes(ctx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
+ if _, err = ComputeIndexes(apiCtx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
&idxSlice, utils.NonTransactional, func(tnt, id, ctx string) (*[]string, error) {
rt, e := dm.GetRouteProfile(tnt, id, true, false, utils.NonTransactional)
if e != nil {
@@ -678,12 +678,12 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
return utils.APIErrorHandler(err)
}
case utils.CacheChargerFilterIndexes:
- if err = removeFilterIndexesForFilter(dm, idxItmType, newFlt.Tenant, // remove the indexes for the filter
+ if err = removeFilterIndexesForFilter(apiCtx, dm, idxItmType, newFlt.Tenant, // remove the indexes for the filter
removeIndexKeys, indx); err != nil {
return
}
idxSlice := indx.AsSlice()
- if _, err = ComputeIndexes(ctx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
+ if _, err = ComputeIndexes(apiCtx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
&idxSlice, utils.NonTransactional, func(tnt, id, ctx string) (*[]string, error) {
ch, e := dm.GetChargerProfile(tnt, id, true, false, utils.NonTransactional)
if e != nil {
@@ -698,12 +698,12 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
return utils.APIErrorHandler(err)
}
case utils.CacheAccountsFilterIndexes:
- if err = removeFilterIndexesForFilter(dm, idxItmType, newFlt.Tenant, //remove the indexes for the filter
+ if err = removeFilterIndexesForFilter(apiCtx, dm, idxItmType, newFlt.Tenant, //remove the indexes for the filter
removeIndexKeys, indx); err != nil {
return
}
idxSlice := indx.AsSlice()
- if _, err = ComputeIndexes(ctx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
+ if _, err = ComputeIndexes(apiCtx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
&idxSlice, utils.NonTransactional, func(tnt, id, ctx string) (*[]string, error) {
ap, e := dm.GetAccount(context.Background(), tnt, id)
if e != nil {
@@ -718,14 +718,14 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
return utils.APIErrorHandler(err)
}
case utils.CacheActionProfilesFilterIndexes:
- if err = removeFilterIndexesForFilter(dm, idxItmType, newFlt.Tenant, //remove the indexes for the filter
+ if err = removeFilterIndexesForFilter(apiCtx, dm, idxItmType, newFlt.Tenant, //remove the indexes for the filter
removeIndexKeys, indx); err != nil {
return
}
idxSlice := indx.AsSlice()
- if _, err = ComputeIndexes(ctx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
+ if _, err = ComputeIndexes(apiCtx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
&idxSlice, utils.NonTransactional, func(tnt, id, ctx string) (*[]string, error) {
- acp, e := dm.GetActionProfile(context.TODO(), tnt, id, true, false, utils.NonTransactional)
+ acp, e := dm.GetActionProfile(apiCtx, tnt, id, true, false, utils.NonTransactional)
if e != nil {
return nil, e
}
@@ -738,14 +738,14 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
return utils.APIErrorHandler(err)
}
case utils.CacheRateProfilesFilterIndexes:
- if err = removeFilterIndexesForFilter(dm, idxItmType, newFlt.Tenant, //remove the indexes for the filter
+ if err = removeFilterIndexesForFilter(apiCtx, dm, idxItmType, newFlt.Tenant, //remove the indexes for the filter
removeIndexKeys, indx); err != nil {
return
}
idxSlice := indx.AsSlice()
- if _, err = ComputeIndexes(ctx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
+ if _, err = ComputeIndexes(apiCtx, dm, newFlt.Tenant, utils.EmptyString, idxItmType, // compute all the indexes for afected items
&idxSlice, utils.NonTransactional, func(tnt, id, ctx string) (*[]string, error) {
- rp, e := dm.GetRateProfile(context.TODO(), tnt, id, true, false, utils.NonTransactional)
+ rp, e := dm.GetRateProfile(apiCtx, tnt, id, true, false, utils.NonTransactional)
if e != nil {
return nil, e
}
@@ -772,12 +772,12 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
}
for rpID, ids := range itemIDs {
tntCtx := utils.ConcatenatedKey(newFlt.Tenant, rpID)
- if err = removeFilterIndexesForFilter(dm, idxItmType, tntCtx,
+ if err = removeFilterIndexesForFilter(apiCtx, dm, idxItmType, tntCtx,
removeIndexKeys, ids); err != nil {
return
}
var rp *utils.RateProfile
- if rp, err = dm.GetRateProfile(context.TODO(), newFlt.Tenant, rpID, true, false, utils.NonTransactional); err != nil {
+ if rp, err = dm.GetRateProfile(apiCtx, newFlt.Tenant, rpID, true, false, utils.NonTransactional); err != nil {
return
}
for itemID := range ids {
@@ -788,7 +788,7 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
refID := guardian.Guardian.GuardIDs(utils.EmptyString,
config.CgrConfig().GeneralCfg().LockingTimeout, idxItmType+tntCtx)
var updIdx map[string]utils.StringSet
- if updIdx, err = newFilterIndex(context.TODO(), dm, idxItmType,
+ if updIdx, err = newFilterIndex(apiCtx, dm, idxItmType,
newFlt.Tenant, rpID, itemID, rate.FilterIDs, newFlt); err != nil {
guardian.Guardian.UnguardIDs(refID)
return
@@ -796,7 +796,7 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
for _, idx := range updIdx {
idx.Add(itemID)
}
- if err = dm.SetIndexes(context.TODO(), idxItmType, tntCtx,
+ if err = dm.SetIndexes(apiCtx, idxItmType, tntCtx,
updIdx, false, utils.NonTransactional); err != nil {
guardian.Guardian.UnguardIDs(refID)
return
@@ -807,13 +807,13 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
case utils.CacheAttributeFilterIndexes:
for itemID := range indx {
var ap *AttributeProfile
- if ap, err = dm.GetAttributeProfile(context.TODO(), newFlt.Tenant, itemID,
+ if ap, err = dm.GetAttributeProfile(apiCtx, newFlt.Tenant, itemID,
true, false, utils.NonTransactional); err != nil {
return
}
for _, ctx := range ap.Contexts {
tntCtx := utils.ConcatenatedKey(newFlt.Tenant, ctx)
- if err = removeFilterIndexesForFilter(dm, idxItmType,
+ if err = removeFilterIndexesForFilter(apiCtx, dm, idxItmType,
tntCtx, // remove the indexes for the filter
removeIndexKeys, indx); err != nil {
return
@@ -821,7 +821,7 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
refID := guardian.Guardian.GuardIDs(utils.EmptyString,
config.CgrConfig().GeneralCfg().LockingTimeout, idxItmType+tntCtx)
var updIdx map[string]utils.StringSet
- if updIdx, err = newFilterIndex(context.TODO(), dm, idxItmType,
+ if updIdx, err = newFilterIndex(apiCtx, dm, idxItmType,
newFlt.Tenant, ctx, itemID, ap.FilterIDs, newFlt); err != nil {
guardian.Guardian.UnguardIDs(refID)
return
@@ -829,7 +829,7 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
for _, idx := range updIdx {
idx.Add(itemID)
}
- if err = dm.SetIndexes(context.TODO(), idxItmType, tntCtx,
+ if err = dm.SetIndexes(apiCtx, idxItmType, tntCtx,
updIdx, false, utils.NonTransactional); err != nil {
guardian.Guardian.UnguardIDs(refID)
return
@@ -840,13 +840,13 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
case utils.CacheDispatcherFilterIndexes:
for itemID := range indx {
var dp *DispatcherProfile
- if dp, err = dm.GetDispatcherProfile(newFlt.Tenant, itemID,
+ if dp, err = dm.GetDispatcherProfile(apiCtx, newFlt.Tenant, itemID,
true, false, utils.NonTransactional); err != nil {
return
}
for _, ctx := range dp.Subsystems {
tntCtx := utils.ConcatenatedKey(newFlt.Tenant, ctx)
- if err = removeFilterIndexesForFilter(dm, idxItmType,
+ if err = removeFilterIndexesForFilter(apiCtx, dm, idxItmType,
tntCtx, // remove the indexes for the filter
removeIndexKeys, indx); err != nil {
return
@@ -854,7 +854,7 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
refID := guardian.Guardian.GuardIDs(utils.EmptyString,
config.CgrConfig().GeneralCfg().LockingTimeout, idxItmType+tntCtx)
var updIdx map[string]utils.StringSet
- if updIdx, err = newFilterIndex(context.TODO(), dm, idxItmType,
+ if updIdx, err = newFilterIndex(apiCtx, dm, idxItmType,
newFlt.Tenant, ctx, itemID, dp.FilterIDs, newFlt); err != nil {
guardian.Guardian.UnguardIDs(refID)
return
@@ -862,7 +862,7 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
for _, idx := range updIdx {
idx.Add(itemID)
}
- if err = dm.SetIndexes(context.TODO(), idxItmType, tntCtx,
+ if err = dm.SetIndexes(apiCtx, idxItmType, tntCtx,
updIdx, false, utils.NonTransactional); err != nil {
guardian.Guardian.UnguardIDs(refID)
return
@@ -877,14 +877,14 @@ func UpdateFilterIndex(ctx *context.Context, dm *DataManager, oldFlt, newFlt *Fi
// removeFilterIndexesForFilter removes the itemID for the index keys
// used to remove the old indexes when a filter is updated
-func removeFilterIndexesForFilter(dm *DataManager, idxItmType, tnt string,
+func removeFilterIndexesForFilter(ctx *context.Context, dm *DataManager, idxItmType, tnt string,
removeIndexKeys []string, itemIDs utils.StringSet) (err error) {
refID := guardian.Guardian.GuardIDs(utils.EmptyString,
config.CgrConfig().GeneralCfg().LockingTimeout, idxItmType+tnt)
defer guardian.Guardian.UnguardIDs(refID)
for _, idxKey := range removeIndexKeys { // delete old filters indexes for this item
var remIndx map[string]utils.StringSet
- if remIndx, err = dm.GetIndexes(context.TODO(), idxItmType, tnt,
+ if remIndx, err = dm.GetIndexes(ctx, idxItmType, tnt,
idxKey, true, false); err != nil {
if err != utils.ErrNotFound {
return
@@ -896,7 +896,7 @@ func removeFilterIndexesForFilter(dm *DataManager, idxItmType, tnt string,
remIndx[idxKey].Remove(idx)
}
- if err = dm.SetIndexes(context.TODO(), idxItmType, tnt, remIndx, true, utils.NonTransactional); err != nil {
+ if err = dm.SetIndexes(ctx, idxItmType, tnt, remIndx, true, utils.NonTransactional); err != nil {
return
}
}
diff --git a/engine/storage_interface.go b/engine/storage_interface.go
index e85910bcc..0b55b16ff 100644
--- a/engine/storage_interface.go
+++ b/engine/storage_interface.go
@@ -84,9 +84,9 @@ type DataDB interface {
GetChargerProfileDrv(string, string) (*ChargerProfile, error)
SetChargerProfileDrv(*ChargerProfile) error
RemoveChargerProfileDrv(string, string) error
- GetDispatcherProfileDrv(string, string) (*DispatcherProfile, error)
- SetDispatcherProfileDrv(*DispatcherProfile) error
- RemoveDispatcherProfileDrv(string, string) error
+ GetDispatcherProfileDrv(*context.Context, string, string) (*DispatcherProfile, error)
+ SetDispatcherProfileDrv(*context.Context, *DispatcherProfile) error
+ RemoveDispatcherProfileDrv(*context.Context, string, string) error
GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[string]int64, err error)
SetLoadIDsDrv(ctx *context.Context, loadIDs map[string]int64) error
RemoveLoadIDsDrv() error
diff --git a/engine/storage_internal_datadb.go b/engine/storage_internal_datadb.go
index 032dec6e7..6290a5128 100644
--- a/engine/storage_internal_datadb.go
+++ b/engine/storage_internal_datadb.go
@@ -399,7 +399,7 @@ func (iDB *InternalDB) RemoveChargerProfileDrv(tenant, id string) (err error) {
return
}
-func (iDB *InternalDB) GetDispatcherProfileDrv(tenant, id string) (dpp *DispatcherProfile, err error) {
+func (iDB *InternalDB) GetDispatcherProfileDrv(ctx *context.Context, tenant, id string) (dpp *DispatcherProfile, err error) {
x, ok := Cache.Get(utils.CacheDispatcherProfiles, utils.ConcatenatedKey(tenant, id))
if !ok || x == nil {
return nil, utils.ErrNotFound
@@ -407,13 +407,13 @@ func (iDB *InternalDB) GetDispatcherProfileDrv(tenant, id string) (dpp *Dispatch
return x.(*DispatcherProfile), nil
}
-func (iDB *InternalDB) SetDispatcherProfileDrv(dpp *DispatcherProfile) (err error) {
+func (iDB *InternalDB) SetDispatcherProfileDrv(ctx *context.Context, dpp *DispatcherProfile) (err error) {
Cache.SetWithoutReplicate(utils.CacheDispatcherProfiles, dpp.TenantID(), dpp, nil,
cacheCommit(utils.NonTransactional), utils.NonTransactional)
return
}
-func (iDB *InternalDB) RemoveDispatcherProfileDrv(tenant, id string) (err error) {
+func (iDB *InternalDB) RemoveDispatcherProfileDrv(ctx *context.Context, tenant, id string) (err error) {
Cache.RemoveWithoutReplicate(utils.CacheDispatcherProfiles, utils.ConcatenatedKey(tenant, id),
cacheCommit(utils.NonTransactional), utils.NonTransactional)
return
diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go
index 2c867144a..b0f7f1198 100644
--- a/engine/storage_mongo_datadb.go
+++ b/engine/storage_mongo_datadb.go
@@ -1175,9 +1175,9 @@ func (ms *MongoStorage) RemoveChargerProfileDrv(tenant, id string) (err error) {
})
}
-func (ms *MongoStorage) GetDispatcherProfileDrv(tenant, id string) (r *DispatcherProfile, err error) {
+func (ms *MongoStorage) GetDispatcherProfileDrv(ctx *context.Context, tenant, id string) (r *DispatcherProfile, err error) {
r = new(DispatcherProfile)
- err = ms.query(context.TODO(), func(sctx mongo.SessionContext) (err error) {
+ err = ms.query(ctx, func(sctx mongo.SessionContext) (err error) {
cur := ms.getCol(ColDpp).FindOne(sctx, bson.M{"tenant": tenant, "id": id})
if err := cur.Decode(r); err != nil {
r = nil
@@ -1191,8 +1191,8 @@ func (ms *MongoStorage) GetDispatcherProfileDrv(tenant, id string) (r *Dispatche
return
}
-func (ms *MongoStorage) SetDispatcherProfileDrv(r *DispatcherProfile) (err error) {
- return ms.query(context.TODO(), func(sctx mongo.SessionContext) (err error) {
+func (ms *MongoStorage) SetDispatcherProfileDrv(ctx *context.Context, r *DispatcherProfile) (err error) {
+ return ms.query(ctx, func(sctx mongo.SessionContext) (err error) {
_, err = ms.getCol(ColDpp).UpdateOne(sctx, bson.M{"tenant": r.Tenant, "id": r.ID},
bson.M{"$set": r},
options.Update().SetUpsert(true),
@@ -1201,8 +1201,8 @@ func (ms *MongoStorage) SetDispatcherProfileDrv(r *DispatcherProfile) (err error
})
}
-func (ms *MongoStorage) RemoveDispatcherProfileDrv(tenant, id string) (err error) {
- return ms.query(context.TODO(), func(sctx mongo.SessionContext) (err error) {
+func (ms *MongoStorage) RemoveDispatcherProfileDrv(ctx *context.Context, tenant, id string) (err error) {
+ return ms.query(ctx, func(sctx mongo.SessionContext) (err error) {
dr, err := ms.getCol(ColDpp).DeleteOne(sctx, bson.M{"tenant": tenant, "id": id})
if dr.DeletedCount == 0 {
return utils.ErrNotFound
diff --git a/engine/storage_redis.go b/engine/storage_redis.go
index c97e4d269..7449b1832 100644
--- a/engine/storage_redis.go
+++ b/engine/storage_redis.go
@@ -637,7 +637,7 @@ func (rs *RedisStorage) RemoveChargerProfileDrv(tenant, id string) (err error) {
return rs.Cmd(nil, redisDEL, utils.ChargerProfilePrefix+utils.ConcatenatedKey(tenant, id))
}
-func (rs *RedisStorage) GetDispatcherProfileDrv(tenant, id string) (r *DispatcherProfile, err error) {
+func (rs *RedisStorage) GetDispatcherProfileDrv(ctx *context.Context, tenant, id string) (r *DispatcherProfile, err error) {
var values []byte
if err = rs.Cmd(&values, redisGET, utils.DispatcherProfilePrefix+utils.ConcatenatedKey(tenant, id)); err != nil {
return
@@ -649,7 +649,7 @@ func (rs *RedisStorage) GetDispatcherProfileDrv(tenant, id string) (r *Dispatche
return
}
-func (rs *RedisStorage) SetDispatcherProfileDrv(r *DispatcherProfile) (err error) {
+func (rs *RedisStorage) SetDispatcherProfileDrv(ctx *context.Context, r *DispatcherProfile) (err error) {
var result []byte
if result, err = rs.ms.Marshal(r); err != nil {
return
@@ -657,7 +657,7 @@ func (rs *RedisStorage) SetDispatcherProfileDrv(r *DispatcherProfile) (err error
return rs.Cmd(nil, redisSET, utils.DispatcherProfilePrefix+utils.ConcatenatedKey(r.Tenant, r.ID), string(result))
}
-func (rs *RedisStorage) RemoveDispatcherProfileDrv(tenant, id string) (err error) {
+func (rs *RedisStorage) RemoveDispatcherProfileDrv(ctx *context.Context, tenant, id string) (err error) {
return rs.Cmd(nil, redisDEL, utils.DispatcherProfilePrefix+utils.ConcatenatedKey(tenant, id))
}
diff --git a/engine/tpreader.go b/engine/tpreader.go
index aa2c6fd82..573272175 100644
--- a/engine/tpreader.go
+++ b/engine/tpreader.go
@@ -618,7 +618,7 @@ func (tpr *TpReader) WriteToDatabase(verbose, disableReverse bool) (err error) {
if th, err = APItoDispatcherProfile(tpTH, tpr.timezone); err != nil {
return
}
- if err = tpr.dm.SetDispatcherProfile(th, true); err != nil {
+ if err = tpr.dm.SetDispatcherProfile(context.TODO(), th, true); err != nil {
return
}
if verbose {
@@ -957,7 +957,7 @@ func (tpr *TpReader) RemoveFromDatabase(verbose, disableReverse bool) (err error
log.Print("DispatcherProfiles:")
}
for _, tpDsp := range tpr.dispatcherProfiles {
- if err = tpr.dm.RemoveDispatcherProfile(tpDsp.Tenant, tpDsp.ID,
+ if err = tpr.dm.RemoveDispatcherProfile(context.TODO(), tpDsp.Tenant, tpDsp.ID,
utils.NonTransactional, true); err != nil {
return
}
diff --git a/engine/version.go b/engine/version.go
index 19de6602b..ec139c34f 100644
--- a/engine/version.go
+++ b/engine/version.go
@@ -145,7 +145,7 @@ func CurrentDataDBVersions() Versions {
utils.Actions: 2,
utils.Thresholds: 4,
utils.Routes: 2,
- utils.Attributes: 7,
+ utils.Attributes: 6,
utils.RQF: 5,
utils.Resource: 1,
utils.Subscribers: 1,
diff --git a/engine/version_test.go b/engine/version_test.go
index 7b5616230..8771f116e 100644
--- a/engine/version_test.go
+++ b/engine/version_test.go
@@ -73,7 +73,7 @@ func TestVersionCompare(t *testing.T) {
func TestCurrentDBVersions(t *testing.T) {
expVersDataDB := Versions{
utils.StatS: 4, utils.Accounts: 3, utils.Actions: 2,
- utils.Thresholds: 4, utils.Routes: 2, utils.Attributes: 7,
+ utils.Thresholds: 4, utils.Routes: 2, utils.Attributes: 6,
utils.RQF: 5, utils.Resource: 1,
utils.Subscribers: 1,
utils.Chargers: 2,
diff --git a/engine/z_filterindexer_it_test.go b/engine/z_filterindexer_it_test.go
index 6256b865e..3621036e4 100644
--- a/engine/z_filterindexer_it_test.go
+++ b/engine/z_filterindexer_it_test.go
@@ -974,9 +974,9 @@ func testITAccountIndexes(t *testing.T) {
},
}
- if err := dataManager.SetAccount(accPrf1, true); err != nil {
+ if err := dataManager.SetAccount(context.TODO(), accPrf1, true); err != nil {
t.Error(err)
- } else if err := dataManager.SetAccount(accPrf2, true); err != nil {
+ } else if err := dataManager.SetAccount(context.TODO(), accPrf2, true); err != nil {
t.Error(err)
}
@@ -1028,7 +1028,7 @@ func testITAccountIndexes(t *testing.T) {
},
},
}
- if err := dataManager.SetAccount(accPrf3, true); err != nil {
+ if err := dataManager.SetAccount(context.TODO(), accPrf3, true); err != nil {
t.Error(err)
}
@@ -1514,10 +1514,10 @@ func testITDispatcherProfileIndexes(t *testing.T) {
Subsystems: []string{"thresholds"},
FilterIDs: []string{"DISPATCHER_FLTR2", "*prefix:23:~*req.Destination"},
}
- if err := dataManager.SetDispatcherProfile(dspPrf1, true); err != nil {
+ if err := dataManager.SetDispatcherProfile(context.TODO(), dspPrf1, true); err != nil {
t.Error(err)
}
- if err := dataManager.SetDispatcherProfile(dspPrf2, true); err != nil {
+ if err := dataManager.SetDispatcherProfile(context.TODO(), dspPrf2, true); err != nil {
t.Error(err)
}
@@ -1610,9 +1610,9 @@ func testITActionProfileIndexes(t *testing.T) {
ID: "ACTPRF2",
FilterIDs: []string{"ACTPRF_FLTR2"},
}
- if err := dataManager.SetActionProfile(actPrf1, true); err != nil {
+ if err := dataManager.SetActionProfile(context.TODO(), actPrf1, true); err != nil {
t.Error(err)
- } else if err := dataManager.SetActionProfile(actPrf2, true); err != nil {
+ } else if err := dataManager.SetActionProfile(context.TODO(), actPrf2, true); err != nil {
t.Error(err)
}
@@ -1680,9 +1680,9 @@ func testITActionProfileIndexes(t *testing.T) {
ID: "CHANGED_ACTPRF2",
FilterIDs: []string{"ACTPRF_FLTR2"},
}
- if err := dataManager.SetActionProfile(actPrf1, true); err != nil {
+ if err := dataManager.SetActionProfile(context.TODO(), actPrf1, true); err != nil {
t.Error(err)
- } else if err := dataManager.SetActionProfile(actPrf2, true); err != nil {
+ } else if err := dataManager.SetActionProfile(context.TODO(), actPrf2, true); err != nil {
t.Error(err)
}
diff --git a/engine/z_loader_it_test.go b/engine/z_loader_it_test.go
index 873583979..d00fc786e 100644
--- a/engine/z_loader_it_test.go
+++ b/engine/z_loader_it_test.go
@@ -105,8 +105,7 @@ func testLoaderITInitDataDB(t *testing.T) {
}
}
cacheChan := make(chan birpc.ClientConnector, 1)
- srv, _ := birpc.NewService(NewCacheS(lCfg, dataDbCsv, nil), "", false)
- srv.UpdateMethodName(func(key string) (newKey string) {
+ srv, _ := birpc.NewServiceWithMethodsRename(NewCacheS(lCfg, dataDbCsv, nil), "", false, func(key string) (newKey string) {
return strings.TrimPrefix(key, "V1")
})
cacheChan <- srv
@@ -335,7 +334,7 @@ func testLoaderITWriteToDatabase(t *testing.T) {
}
for tenatid, dpp := range loader.dispatcherProfiles {
- rcv, err := loader.dm.GetDispatcherProfile(tenatid.Tenant, tenatid.ID, false, false, utils.NonTransactional)
+ rcv, err := loader.dm.GetDispatcherProfile(context.TODO(), tenatid.Tenant, tenatid.ID, false, false, utils.NonTransactional)
if err != nil {
t.Errorf("Failed GetDispatcherProfile, tenant: %s, id: %s, error: %s ", dpp.Tenant, dpp.ID, err.Error())
}
diff --git a/engine/z_onstor_it_test.go b/engine/z_onstor_it_test.go
index a5f6df674..1067f02d0 100644
--- a/engine/z_onstor_it_test.go
+++ b/engine/z_onstor_it_test.go
@@ -965,15 +965,15 @@ func testOnStorITDispatcherProfile(t *testing.T) {
// Hosts: []string{"192.168.56.203"},
Weight: 20,
}
- if _, rcvErr := onStor.GetDispatcherProfile("cgrates.org", "Dsp1",
+ if _, rcvErr := onStor.GetDispatcherProfile(context.TODO(), "cgrates.org", "Dsp1",
true, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound {
t.Error(rcvErr)
}
- if err := onStor.SetDispatcherProfile(dpp, false); err != nil {
+ if err := onStor.SetDispatcherProfile(context.TODO(), dpp, false); err != nil {
t.Error(err)
}
//get from database
- if rcv, err := onStor.GetDispatcherProfile("cgrates.org", "Dsp1",
+ if rcv, err := onStor.GetDispatcherProfile(context.TODO(), "cgrates.org", "Dsp1",
false, false, utils.NonTransactional); err != nil {
t.Error(err)
} else if !(reflect.DeepEqual(dpp, rcv)) {
@@ -987,23 +987,23 @@ func testOnStorITDispatcherProfile(t *testing.T) {
}
//update
dpp.FilterIDs = []string{"*string:~*req.Accout:1001", "*prefix:~*req.Destination:10"}
- if err := onStor.SetDispatcherProfile(dpp, false); err != nil {
+ if err := onStor.SetDispatcherProfile(context.TODO(), dpp, false); err != nil {
t.Error(err)
}
//get from database
- if rcv, err := onStor.GetDispatcherProfile("cgrates.org", "Dsp1",
+ if rcv, err := onStor.GetDispatcherProfile(context.TODO(), "cgrates.org", "Dsp1",
false, false, utils.NonTransactional); err != nil {
t.Error(err)
} else if !(reflect.DeepEqual(dpp, rcv)) {
t.Errorf("Expecting: %v, received: %v", dpp, rcv)
}
- if err := onStor.RemoveDispatcherProfile(dpp.Tenant, dpp.ID,
+ if err := onStor.RemoveDispatcherProfile(context.TODO(), dpp.Tenant, dpp.ID,
utils.NonTransactional, false); err != nil {
t.Error(err)
}
//check database if removed
- if _, rcvErr := onStor.GetDispatcherProfile("cgrates.org", "Dsp1",
+ if _, rcvErr := onStor.GetDispatcherProfile(context.TODO(), "cgrates.org", "Dsp1",
false, false, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound {
t.Error(rcvErr)
}
@@ -1121,16 +1121,16 @@ func testOnStorITActionProfile(t *testing.T) {
}
//empty in database
- if _, err := onStor.GetActionProfile("cgrates.org", "TEST_ID1",
+ if _, err := onStor.GetActionProfile(context.TODO(), "cgrates.org", "TEST_ID1",
true, false, utils.NonTransactional); err != utils.ErrNotFound {
t.Error(err)
}
//get from database
- if err := onStor.SetActionProfile(actPrf, false); err != nil {
+ if err := onStor.SetActionProfile(context.TODO(), actPrf, false); err != nil {
t.Error(err)
}
- if rcv, err := onStor.GetActionProfile("cgrates.org", "TEST_ID1",
+ if rcv, err := onStor.GetActionProfile(context.TODO(), "cgrates.org", "TEST_ID1",
true, false, utils.NonTransactional); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(rcv, actPrf) {
@@ -1147,9 +1147,9 @@ func testOnStorITActionProfile(t *testing.T) {
//updateFilters
actPrf.FilterIDs = []string{"*prefix:~*req.Destination:10"}
- if err := onStor.SetActionProfile(actPrf, false); err != nil {
+ if err := onStor.SetActionProfile(context.TODO(), actPrf, false); err != nil {
t.Error(err)
- } else if rcv, err := onStor.GetActionProfile("cgrates.org", "TEST_ID1",
+ } else if rcv, err := onStor.GetActionProfile(context.TODO(), "cgrates.org", "TEST_ID1",
false, false, utils.NonTransactional); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(actPrf, rcv) {
@@ -1157,10 +1157,10 @@ func testOnStorITActionProfile(t *testing.T) {
}
//remove from database
- if err := onStor.RemoveActionProfile("cgrates.org", "TEST_ID1",
+ if err := onStor.RemoveActionProfile(context.TODO(), "cgrates.org", "TEST_ID1",
utils.NonTransactional, false); err != nil {
t.Error(err)
- } else if _, err := onStor.GetActionProfile("cgrates.org", "TEST_ID1",
+ } else if _, err := onStor.GetActionProfile(context.TODO(), "cgrates.org", "TEST_ID1",
false, false, utils.NonTransactional); err != utils.ErrNotFound {
t.Error(err)
}
@@ -1197,15 +1197,15 @@ func testOnStorITAccount(t *testing.T) {
}
//empty in database
- if _, err := onStor.GetAccount("cgrates.org", "RP1"); err != utils.ErrNotFound {
+ if _, err := onStor.GetAccount(context.TODO(), "cgrates.org", "RP1"); err != utils.ErrNotFound {
t.Error(err)
}
//get from database
- if err := onStor.SetAccount(acctPrf, false); err != nil {
+ if err := onStor.SetAccount(context.TODO(), acctPrf, false); err != nil {
t.Error(err)
}
- if rcv, err := onStor.GetAccount("cgrates.org", "RP1"); err != nil {
+ if rcv, err := onStor.GetAccount(context.TODO(), "cgrates.org", "RP1"); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(rcv, acctPrf) {
t.Errorf("Expecting: %v, received: %v", acctPrf, rcv)
@@ -1221,19 +1221,19 @@ func testOnStorITAccount(t *testing.T) {
//updateFilters
acctPrf.FilterIDs = []string{"*prefix:~*req.Destination:10"}
- if err := onStor.SetAccount(acctPrf, false); err != nil {
+ if err := onStor.SetAccount(context.TODO(), acctPrf, false); err != nil {
t.Error(err)
- } else if rcv, err := onStor.GetAccount("cgrates.org", "RP1"); err != nil {
+ } else if rcv, err := onStor.GetAccount(context.TODO(), "cgrates.org", "RP1"); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(acctPrf, rcv) {
t.Errorf("Expecting: %v, received: %v", acctPrf, rcv)
}
//remove from database
- if err := onStor.RemoveAccount("cgrates.org", "RP1",
+ if err := onStor.RemoveAccount(context.TODO(), "cgrates.org", "RP1",
utils.NonTransactional, false); err != nil {
t.Error(err)
- } else if _, err := onStor.GetAccount("cgrates.org", "RP1"); err != utils.ErrNotFound {
+ } else if _, err := onStor.GetAccount(context.TODO(), "cgrates.org", "RP1"); err != utils.ErrNotFound {
t.Error(err)
}
}
diff --git a/general_tests/attributes_filters_index_it_test.go b/general_tests/attributes_filters_index_it_test.go
new file mode 100644
index 000000000..240c5cd62
--- /dev/null
+++ b/general_tests/attributes_filters_index_it_test.go
@@ -0,0 +1,286 @@
+// +build integration
+
+/*
+Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
+Copyright (C) ITsysCOM GmbH
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package general_tests
+
+import (
+ "net/rpc"
+ "path"
+ "reflect"
+ "testing"
+
+ "github.com/cgrates/cgrates/apis"
+ "github.com/cgrates/cgrates/engine"
+
+ "github.com/cgrates/cgrates/config"
+ "github.com/cgrates/cgrates/utils"
+)
+
+var (
+ attrFltrCfgPath string
+ attrFltrCfg *config.CGRConfig
+ attrFltrRPC *rpc.Client
+ alsPrfFltrConfigDIR string
+ sTestsAlsFltrPrf = []func(t *testing.T){
+ testAttributeFltrSInitCfg,
+ testAttributeFltrSInitDataDb,
+ testAttributeFltrSResetStorDb,
+ testAttributeFltrSStartEngine,
+ testAttributeFltrSRPCConn,
+
+ testAttributeSetFltr1,
+ testAttributeSetProfile,
+ testAttributeSetFltr2,
+ testAttributeRemoveFltr,
+
+ testAttributeFltrSStopEngine,
+ }
+)
+
+func TestAttributeFilterSIT(t *testing.T) {
+ switch *dbType {
+ case utils.MetaMySQL:
+ alsPrfFltrConfigDIR = "attributesindexes_mysql"
+ case utils.MetaMongo:
+ alsPrfFltrConfigDIR = "attributesindexes_mongo"
+ case utils.MetaPostgres, utils.MetaInternal:
+ t.SkipNow()
+ default:
+ t.Fatal("Unknown Database type")
+ }
+ for _, stest := range sTestsAlsFltrPrf {
+ t.Run(alsPrfFltrConfigDIR, stest)
+ }
+}
+
+func testAttributeFltrSInitCfg(t *testing.T) {
+ var err error
+ attrFltrCfgPath = path.Join(*dataDir, "conf", "samples", alsPrfFltrConfigDIR)
+ attrFltrCfg, err = config.NewCGRConfigFromPath(attrFltrCfgPath)
+ if err != nil {
+ t.Error(err)
+ }
+ attrFltrCfg.DataFolderPath = *dataDir // Share DataFolderPath through config towards StoreDb for Flush()
+}
+
+func testAttributeFltrSInitDataDb(t *testing.T) {
+ if err := engine.InitDataDB(attrFltrCfg); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// Wipe out the cdr database
+func testAttributeFltrSResetStorDb(t *testing.T) {
+ if err := engine.InitStorDB(attrFltrCfg); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// Start CGR Engine
+func testAttributeFltrSStartEngine(t *testing.T) {
+ if _, err := engine.StopStartEngine(attrFltrCfgPath, *waitRater); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// Connect rpc client to rater
+func testAttributeFltrSRPCConn(t *testing.T) {
+ var err error
+ attrFltrRPC, err = newRPCClient(attrFltrCfg.ListenCfg()) // We connect over JSON so we can also troubleshoot if needed
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
+func testAttributeSetFltr1(t *testing.T) {
+ filter := &engine.FilterWithAPIOpts{
+ Filter: &engine.Filter{
+ Tenant: "cgrates.org",
+ ID: "FLTR_1",
+ Rules: []*engine.FilterRule{{
+ Element: "~*req.Subject",
+ Type: "*prefix",
+ Values: []string{"48"},
+ }},
+ },
+ }
+ var result string
+ if err := attrFltrRPC.Call(utils.AdminSv1SetFilter, filter, &result); err != nil {
+ t.Error(err)
+ } else if result != utils.OK {
+ t.Error("Unexpected reply returned", result)
+ }
+
+ var indexes []string
+ if err := attrFltrRPC.Call(utils.AdminSv1GetFilterIndexes, &apis.AttrGetFilterIndexes{
+ ItemType: utils.MetaAttributes, Tenant: "cgrates.org", FilterType: utils.MetaPrefix,
+ Context: utils.MetaSessionS},
+ &indexes); err == nil || err.Error() != utils.ErrNotFound.Error() {
+ t.Error(err)
+ }
+}
+
+func testAttributeSetProfile(t *testing.T) {
+ var result string
+ alsPrf := &engine.AttributeWithAPIOpts{
+ APIAttributeProfile: &engine.APIAttributeProfile{
+ Tenant: "cgrates.org",
+ ID: "ApierTest",
+ Contexts: []string{utils.MetaSessionS},
+ FilterIDs: []string{"FLTR_1"},
+ Attributes: []*engine.ExternalAttribute{{
+ Path: "*req.FL1",
+ Value: "Al1",
+ }},
+ Weight: 20,
+ },
+ }
+ if err := attrFltrRPC.Call(utils.AdminSv1SetAttributeProfile, alsPrf, &result); err != nil {
+ t.Error(err)
+ } else if result != utils.OK {
+ t.Error("Unexpected reply returned", result)
+ }
+
+ ev := &engine.AttrArgsProcessEvent{
+ Context: utils.StringPointer(utils.MetaSessionS),
+ CGREvent: &utils.CGREvent{
+ Tenant: "cgrates.org",
+ Event: map[string]interface{}{
+ "Subject": "44",
+ },
+ APIOpts: map[string]interface{}{},
+ },
+ }
+ var rplyEv engine.AttrSProcessEventReply
+ if err := attrFltrRPC.Call(utils.AttributeSv1ProcessEvent,
+ ev, &rplyEv); err == nil || err.Error() != utils.ErrNotFound.Error() {
+ t.Errorf("Expected %+v, received %+v", utils.ErrNotFound, err)
+ }
+
+ var indexes []string
+ expIdx := []string{
+ "*prefix:*req.Subject:48:ApierTest",
+ }
+ if err := attrFltrRPC.Call(utils.AdminSv1GetFilterIndexes, &apis.AttrGetFilterIndexes{
+ ItemType: utils.MetaAttributes, Tenant: "cgrates.org", FilterType: utils.MetaPrefix,
+ Context: utils.MetaSessionS},
+ &indexes); err != nil {
+ t.Error(err)
+ } else if !reflect.DeepEqual(indexes, expIdx) {
+ t.Errorf("Expecting: %+v, received: %+v",
+ utils.ToJSON(expIdx), utils.ToJSON(indexes))
+ }
+}
+
+func testAttributeSetFltr2(t *testing.T) {
+ var result string
+ filter := &engine.FilterWithAPIOpts{
+ Filter: &engine.Filter{
+ Tenant: "cgrates.org",
+ ID: "FLTR_1",
+ Rules: []*engine.FilterRule{{
+ Element: "~*req.Subject",
+ Type: "*prefix",
+ Values: []string{"44"},
+ }},
+ },
+ }
+ if err := attrFltrRPC.Call(utils.AdminSv1SetFilter, filter, &result); err != nil {
+ t.Error(err)
+ } else if result != utils.OK {
+ t.Error("Unexpected reply returned", result)
+ }
+
+ //same event for process
+ ev := &engine.AttrArgsProcessEvent{
+ Context: utils.StringPointer(utils.MetaSessionS),
+ CGREvent: &utils.CGREvent{
+ Tenant: "cgrates.org",
+ Event: map[string]interface{}{
+ "Subject": "4444",
+ },
+ APIOpts: map[string]interface{}{},
+ },
+ }
+ exp := engine.AttrSProcessEventReply{
+ MatchedProfiles: []string{"ApierTest"},
+ AlteredFields: []string{"*req.FL1"},
+ CGREvent: &utils.CGREvent{
+ Tenant: "cgrates.org",
+ Event: map[string]interface{}{
+ "Subject": "4444",
+ "FL1": "Al1",
+ },
+ APIOpts: map[string]interface{}{},
+ },
+ }
+ var rplyEv engine.AttrSProcessEventReply
+ if err := attrFltrRPC.Call(utils.AttributeSv1ProcessEvent,
+ ev, &rplyEv); err != nil {
+ t.Fatal(err)
+ } else if !reflect.DeepEqual(exp, rplyEv) {
+ t.Errorf("Expected %s, received %s", utils.ToJSON(exp), utils.ToJSON(rplyEv))
+ }
+
+ var indexes []string
+ expIdx := []string{
+ "*prefix:*req.Subject:44:ApierTest",
+ }
+ if err := attrFltrRPC.Call(utils.AdminSv1GetFilterIndexes, &apis.AttrGetFilterIndexes{
+ ItemType: utils.MetaAttributes, Tenant: "cgrates.org", FilterType: utils.MetaPrefix,
+ Context: utils.MetaSessionS},
+ &indexes); err != nil {
+ t.Error(err)
+ } else if !reflect.DeepEqual(indexes, expIdx) {
+ t.Errorf("Expecting: %+v, received: %+v",
+ utils.ToJSON(expIdx), utils.ToJSON(indexes))
+ }
+}
+
+func testAttributeRemoveFltr(t *testing.T) {
+ var result string
+ if err := attrFltrRPC.Call(utils.AdminSv1RemoveAttributeProfile, &utils.TenantIDWithAPIOpts{
+ TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}}, &result); err != nil {
+ t.Error(err)
+ } else if result != utils.OK {
+ t.Error("Unexpected reply returned", result)
+ }
+
+ if err := attrFltrRPC.Call(utils.AdminSv1RemoveFilter, &utils.TenantIDWithAPIOpts{
+ TenantID: &utils.TenantID{Tenant: "cgrates.org", ID: "FLTR_1"}}, &result); err != nil {
+ t.Error(err)
+ } else if result != utils.OK {
+ t.Error("Unexpected reply returned", result)
+ }
+
+ var indexes []string
+ if err := attrFltrRPC.Call(utils.AdminSv1GetFilterIndexes, &apis.AttrGetFilterIndexes{
+ ItemType: utils.MetaAttributes, Tenant: "cgrates.org", FilterType: utils.MetaPrefix,
+ Context: utils.MetaSessionS},
+ &indexes); err == nil || err.Error() != utils.ErrNotFound.Error() {
+ t.Error(err)
+ }
+}
+
+func testAttributeFltrSStopEngine(t *testing.T) {
+ if err := engine.KillEngine(*waitRater); err != nil {
+ t.Error(err)
+ }
+}
diff --git a/loaders/loader.go b/loaders/loader.go
index 50c2f4f42..6c4e2cc76 100644
--- a/loaders/loader.go
+++ b/loaders/loader.go
@@ -541,7 +541,7 @@ func (ldr *Loader) storeLoadedData(ctx *context.Context, loaderType string,
}
// get IDs so we can reload in cache
ids = append(ids, dsp.TenantID())
- if err := ldr.dm.SetDispatcherProfile(dsp, true); err != nil {
+ if err := ldr.dm.SetDispatcherProfile(context.TODO(), dsp, true); err != nil {
return err
}
cacheArgs[utils.DispatcherProfileIDs] = ids
@@ -900,7 +900,7 @@ func (ldr *Loader) removeLoadedData(ctx *context.Context, loaderType string, lds
tntIDStruct := utils.NewTenantID(tntID)
// get IDs so we can reload in cache
ids = append(ids, tntID)
- if err := ldr.dm.RemoveDispatcherProfile(tntIDStruct.Tenant,
+ if err := ldr.dm.RemoveDispatcherProfile(context.TODO(), tntIDStruct.Tenant,
tntIDStruct.ID, utils.NonTransactional, true); err != nil {
return err
}
diff --git a/loaders/loader_it_test.go b/loaders/loader_it_test.go
index 486d6b8db..d8dde36e7 100644
--- a/loaders/loader_it_test.go
+++ b/loaders/loader_it_test.go
@@ -32,6 +32,7 @@ import (
"testing"
"time"
+ "github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
@@ -482,7 +483,7 @@ cgrates.org,SET_ACTPROFILE_3
Targets: map[string]utils.StringSet{},
Actions: []*engine.APAction{},
}
- if rcv, err := ldr.dm.GetActionProfile(expACtPrf.Tenant, expACtPrf.ID,
+ if rcv, err := ldr.dm.GetActionProfile(context.TODO(), expACtPrf.Tenant, expACtPrf.ID,
true, true, utils.NonTransactional); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expACtPrf, rcv) {
@@ -605,14 +606,14 @@ cgrates.org,SET_ACTPROFILE_3
Targets: map[string]utils.StringSet{},
Actions: []*engine.APAction{},
}
- if err := ldr.dm.SetActionProfile(expACtPrf, true); err != nil {
+ if err := ldr.dm.SetActionProfile(context.TODO(), expACtPrf, true); err != nil {
t.Error(err)
}
if err := ldr.ProcessFolder(utils.EmptyString, utils.MetaRemove, true); err != nil {
t.Error(err)
}
//nothing to get from database
- if _, err := ldr.dm.GetActionProfile(expACtPrf.Tenant, expACtPrf.ID,
+ if _, err := ldr.dm.GetActionProfile(context.TODO(), expACtPrf.Tenant, expACtPrf.ID,
true, true, utils.NonTransactional); err != utils.ErrNotFound {
t.Error(err)
}
@@ -631,7 +632,7 @@ cgrates.org,SET_ACTPROFILE_3
},
},
}
- if err := ldr.dm.SetActionProfile(expACtPrf, true); err != nil {
+ if err := ldr.dm.SetActionProfile(context.TODO(), expACtPrf, true); err != nil {
t.Error(err)
}
if err := ldr.ProcessFolder(utils.MetaReload, utils.MetaRemove, true); err != utils.ErrNotFound {
diff --git a/loaders/loader_test.go b/loaders/loader_test.go
index 992627a11..841120a85 100644
--- a/loaders/loader_test.go
+++ b/loaders/loader_test.go
@@ -1222,7 +1222,7 @@ func TestLoaderProcessDispatches(t *testing.T) {
},
}
- rcv, err := ldr.dm.GetDispatcherProfile("cgrates.org", "D1",
+ rcv, err := ldr.dm.GetDispatcherProfile(context.TODO(), "cgrates.org", "D1",
true, false, utils.NonTransactional)
if err != nil {
t.Fatal(err)
@@ -3858,7 +3858,7 @@ cgrates.org,REM_DISPATCHERS_1
Tenant: "cgrates.org",
ID: "REM_DISPATCHERS_1",
}
- if err := ldr.dm.SetDispatcherProfile(expDispatchers, true); err != nil {
+ if err := ldr.dm.SetDispatcherProfile(context.TODO(), expDispatchers, true); err != nil {
t.Error(err)
} else if err := ldr.removeContent(context.Background(), utils.MetaDispatchers, utils.EmptyString); err != nil {
t.Error(err)
diff --git a/migrator/dispatchers.go b/migrator/dispatchers.go
index 3995543fb..d5c03e5f3 100644
--- a/migrator/dispatchers.go
+++ b/migrator/dispatchers.go
@@ -39,17 +39,17 @@ func (m *Migrator) migrateCurrentDispatcher() (err error) {
if len(tntID) < 2 {
return fmt.Errorf("Invalid key <%s> when migrating dispatcher profiles", id)
}
- dpp, err := m.dmIN.DataManager().GetDispatcherProfile(tntID[0], tntID[1], false, false, utils.NonTransactional)
+ dpp, err := m.dmIN.DataManager().GetDispatcherProfile(context.TODO(), tntID[0], tntID[1], false, false, utils.NonTransactional)
if err != nil {
return err
}
if dpp == nil || m.dryRun {
continue
}
- if err := m.dmOut.DataManager().SetDispatcherProfile(dpp, true); err != nil {
+ if err := m.dmOut.DataManager().SetDispatcherProfile(context.TODO(), dpp, true); err != nil {
return err
}
- if err := m.dmIN.DataManager().RemoveDispatcherProfile(tntID[0],
+ if err := m.dmIN.DataManager().RemoveDispatcherProfile(context.TODO(), tntID[0],
tntID[1], utils.NonTransactional, false); err != nil {
return err
}
@@ -130,7 +130,7 @@ func (m *Migrator) migrateDispatchers() (err error) {
if !m.dryRun {
//set action plan
- if err = m.dmOut.DataManager().SetDispatcherProfile(v2, true); err != nil {
+ if err = m.dmOut.DataManager().SetDispatcherProfile(context.TODO(), v2, true); err != nil {
return
}
}
diff --git a/migrator/dispatchers_it_test.go b/migrator/dispatchers_it_test.go
index 293b3a2f3..b87f63820 100644
--- a/migrator/dispatchers_it_test.go
+++ b/migrator/dispatchers_it_test.go
@@ -26,6 +26,7 @@ import (
"reflect"
"testing"
+ "github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
@@ -189,7 +190,7 @@ func testDspITMigrateAndMove(t *testing.T) {
Transport: utils.MetaJSON,
},
}
- if err := dspMigrator.dmIN.DataManager().SetDispatcherProfile(dspPrf, false); err != nil {
+ if err := dspMigrator.dmIN.DataManager().SetDispatcherProfile(context.TODO(), dspPrf, false); err != nil {
t.Error(err)
}
if err := dspMigrator.dmIN.DataManager().SetDispatcherHost(dspHost); err != nil {
@@ -201,7 +202,7 @@ func testDspITMigrateAndMove(t *testing.T) {
t.Error("Error when setting version for Dispatchers ", err.Error())
}
- _, err = dspMigrator.dmOut.DataManager().GetDispatcherProfile("cgrates.org",
+ _, err = dspMigrator.dmOut.DataManager().GetDispatcherProfile(context.TODO(), "cgrates.org",
"Dsp1", false, false, utils.NonTransactional)
if err != utils.ErrNotFound {
t.Error(err)
@@ -211,7 +212,7 @@ func testDspITMigrateAndMove(t *testing.T) {
if err != nil {
t.Error("Error when migrating Dispatchers ", err.Error())
}
- result, err := dspMigrator.dmOut.DataManager().GetDispatcherProfile("cgrates.org",
+ result, err := dspMigrator.dmOut.DataManager().GetDispatcherProfile(context.TODO(), "cgrates.org",
"Dsp1", false, false, utils.NonTransactional)
if err != nil {
t.Error(err)
@@ -219,7 +220,7 @@ func testDspITMigrateAndMove(t *testing.T) {
if !reflect.DeepEqual(result, dspPrf) {
t.Errorf("Expecting: %+v, received: %+v", dspPrf, result)
}
- result, err = dspMigrator.dmIN.DataManager().GetDispatcherProfile("cgrates.org",
+ result, err = dspMigrator.dmIN.DataManager().GetDispatcherProfile(context.TODO(), "cgrates.org",
"Dsp1", false, false, utils.NonTransactional)
if err != utils.ErrNotFound {
t.Error(err)
diff --git a/migrator/filters.go b/migrator/filters.go
index b0fde2421..5bb2f258b 100644
--- a/migrator/filters.go
+++ b/migrator/filters.go
@@ -552,7 +552,7 @@ func (m *Migrator) migrateDispatcherProfileFiltersV1() (err error) {
if len(tntID) < 2 {
return fmt.Errorf("Invalid key <%s> when migrating filter for dispatcherProfile", id)
}
- dpp, err := m.dmIN.DataManager().GetDispatcherProfile(tntID[0], tntID[1], false, false, utils.NonTransactional)
+ dpp, err := m.dmIN.DataManager().GetDispatcherProfile(context.TODO(), tntID[0], tntID[1], false, false, utils.NonTransactional)
if err != nil {
return err
}
@@ -562,7 +562,7 @@ func (m *Migrator) migrateDispatcherProfileFiltersV1() (err error) {
for i, fl := range dpp.FilterIDs {
dpp.FilterIDs[i] = migrateInlineFilter(fl)
}
- if err := m.dmOut.DataManager().SetDispatcherProfile(dpp, true); err != nil {
+ if err := m.dmOut.DataManager().SetDispatcherProfile(context.TODO(), dpp, true); err != nil {
return err
}
m.stats[utils.RQF]++
@@ -773,7 +773,7 @@ func (m *Migrator) migrateDispatcherProfileFiltersV2() (err error) {
if len(tntID) < 2 {
return fmt.Errorf("Invalid key <%s> when migrating filter for dispatcherProfile", id)
}
- dpp, err := m.dmIN.DataManager().GetDispatcherProfile(tntID[0], tntID[1], false, false, utils.NonTransactional)
+ dpp, err := m.dmIN.DataManager().GetDispatcherProfile(context.TODO(), tntID[0], tntID[1], false, false, utils.NonTransactional)
if err != nil {
return fmt.Errorf("error: <%s> when getting dispatcher profile with tenant: <%s> and id: <%s>",
err.Error(), tntID[0], tntID[1])
@@ -784,7 +784,7 @@ func (m *Migrator) migrateDispatcherProfileFiltersV2() (err error) {
for i, fl := range dpp.FilterIDs {
dpp.FilterIDs[i] = migrateInlineFilterV2(fl)
}
- if err := m.dmOut.DataManager().SetDispatcherProfile(dpp, true); err != nil {
+ if err := m.dmOut.DataManager().SetDispatcherProfile(context.TODO(), dpp, true); err != nil {
return fmt.Errorf("error: <%s> when setting dispatcher profile with tenant: <%s> and id: <%s>",
err.Error(), tntID[0], tntID[1])
}
diff --git a/migrator/filters_it_test.go b/migrator/filters_it_test.go
index 4a7f422e8..6df41492c 100644
--- a/migrator/filters_it_test.go
+++ b/migrator/filters_it_test.go
@@ -26,6 +26,7 @@ import (
"reflect"
"testing"
+ "github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
@@ -194,16 +195,16 @@ func testFltrITMigrateAndMove(t *testing.T) {
if err := fltrMigrator.dmIN.setV1Filter(fltr); err != nil {
t.Error("Error when setting v1 Filters ", err.Error())
}
- if err := fltrMigrator.dmIN.DataManager().SetAttributeProfile(attrProf, false); err != nil {
+ if err := fltrMigrator.dmIN.DataManager().SetAttributeProfile(context.TODO(), attrProf, false); err != nil {
t.Error("Error when setting attribute profile for v1 Filters ", err.Error())
}
- // manually set the indexes because the GetFilter functions compile the value from DB that is still the old version
+ // manually set the indexes because the GetFilter context.TODO(),functions compile the value from DB that is still the old version
wrongFltrIdx := map[string]utils.StringSet{
"*prefix::1001": {"ATTR_1": struct{}{}},
// "*string:Account:1001": {"ATTR_1": struct{}{}},
}
- if err := fltrMigrator.dmIN.DataManager().SetIndexes(
+ if err := fltrMigrator.dmIN.DataManager().SetIndexes(context.TODO(),
utils.CacheAttributeFilterIndexes,
utils.ConcatenatedKey(attrProf.Tenant, utils.MetaAny),
wrongFltrIdx, false, ""); err != nil {
@@ -213,7 +214,7 @@ func testFltrITMigrateAndMove(t *testing.T) {
wrongFltrIdx = map[string]utils.StringSet{
utils.CacheAttributeFilterIndexes: {"ATTR_1": struct{}{}},
}
- if err := fltrMigrator.dmIN.DataManager().SetIndexes(
+ if err := fltrMigrator.dmIN.DataManager().SetIndexes(context.TODO(),
utils.CacheReverseFilterIndexes,
"cgrates.org:FLTR_2",
wrongFltrIdx, false, ""); err != nil {
@@ -243,7 +244,7 @@ func testFltrITMigrateAndMove(t *testing.T) {
t.Errorf("Unexpected version returned: %d", vrs[utils.RQF])
}
//check if Filters was migrate correctly
- result, err := fltrMigrator.dmOut.DataManager().GetFilter(fltr.Tenant, fltr.ID, false, false, utils.NonTransactional)
+ result, err := fltrMigrator.dmOut.DataManager().GetFilter(context.TODO(), fltr.Tenant, fltr.ID, false, false, utils.NonTransactional)
if err != nil {
t.Fatalf("Error when getting Attributes %v", err.Error())
}
@@ -252,7 +253,7 @@ func testFltrITMigrateAndMove(t *testing.T) {
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expFilters), utils.ToJSON(result))
}
- resultattr, err := fltrMigrator.dmOut.DataManager().DataDB().GetAttributeProfileDrv(attrProf.Tenant, attrProf.ID)
+ resultattr, err := fltrMigrator.dmOut.DataManager().DataDB().GetAttributeProfileDrv(context.TODO(), attrProf.Tenant, attrProf.ID)
if err != nil {
t.Fatalf("Error when getting Attributes %v", err.Error())
}
@@ -266,7 +267,7 @@ func testFltrITMigrateAndMove(t *testing.T) {
"*prefix:*req.Account:1001": {"ATTR_1": struct{}{}},
"*string:*req.Account:1001": {"ATTR_1": struct{}{}}}
- if fltridx, err := fltrMigrator.dmOut.DataManager().GetIndexes(
+ if fltridx, err := fltrMigrator.dmOut.DataManager().GetIndexes(context.TODO(),
utils.CacheAttributeFilterIndexes,
utils.ConcatenatedKey(attrProf.Tenant, utils.MetaAny),
"", false, false); err != nil {
@@ -276,7 +277,7 @@ func testFltrITMigrateAndMove(t *testing.T) {
}
}
case utils.Move:
- if err := fltrMigrator.dmIN.DataManager().SetFilter(expFilters, true); err != nil {
+ if err := fltrMigrator.dmIN.DataManager().SetFilter(context.TODO(), expFilters, true); err != nil {
t.Error(err)
}
currentVersion := engine.CurrentDataDBVersions()
@@ -290,7 +291,7 @@ func testFltrITMigrateAndMove(t *testing.T) {
t.Error("Error when fltrMigratorrating Filters ", err.Error())
}
//check if account was migrate correctly
- result, err := fltrMigrator.dmOut.DataManager().GetFilter(expFilters.Tenant, expFilters.ID, false, false, utils.NonTransactional)
+ result, err := fltrMigrator.dmOut.DataManager().GetFilter(context.TODO(), expFilters.Tenant, expFilters.ID, false, false, utils.NonTransactional)
if err != nil {
t.Error(err)
}
@@ -299,7 +300,7 @@ func testFltrITMigrateAndMove(t *testing.T) {
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expFilters), utils.ToJSON(result))
}
// check if old account was deleted
- result, err = fltrMigrator.dmIN.DataManager().GetFilter(expFilters.Tenant, expFilters.ID, false, false, utils.NonTransactional)
+ result, err = fltrMigrator.dmIN.DataManager().GetFilter(context.TODO(), expFilters.Tenant, expFilters.ID, false, false, utils.NonTransactional)
if err != utils.ErrNotFound {
t.Error(err)
}
@@ -387,16 +388,16 @@ func testFltrITMigratev2(t *testing.T) {
if err := fltrMigrator.dmIN.setV1Filter(filters); err != nil {
t.Error("Error when setting v1 Filters ", err.Error())
}
- if err := fltrMigrator.dmIN.DataManager().SetAttributeProfile(attrProf, false); err != nil {
+ if err := fltrMigrator.dmIN.DataManager().SetAttributeProfile(context.TODO(), attrProf, false); err != nil {
t.Error("Error when setting attribute profile for v1 Filters ", err.Error())
}
- // manually set the indexes because the GetFilter functions compile the value from DB that is still the old version
+ // manually set the indexes because the GetFilter context.TODO(),functions compile the value from DB that is still the old version
wrongFltrIdx := map[string]utils.StringSet{
"*string::1001": {"ATTR_1": struct{}{}},
"*string:~Account:1001": {"ATTR_1": struct{}{}}}
- if err := fltrMigrator.dmIN.DataManager().SetIndexes(
+ if err := fltrMigrator.dmIN.DataManager().SetIndexes(context.TODO(),
utils.CacheAttributeFilterIndexes,
utils.ConcatenatedKey(attrProf.Tenant, utils.MetaAny),
wrongFltrIdx, false, ""); err != nil {
@@ -406,7 +407,7 @@ func testFltrITMigratev2(t *testing.T) {
wrongFltrIdx = map[string]utils.StringSet{
utils.CacheAttributeFilterIndexes: {"ATTR_1": struct{}{}},
}
- if err := fltrMigrator.dmIN.DataManager().SetIndexes(
+ if err := fltrMigrator.dmIN.DataManager().SetIndexes(context.TODO(),
utils.CacheReverseFilterIndexes,
"cgrates.org:FLTR_2",
wrongFltrIdx, false, ""); err != nil {
@@ -437,7 +438,7 @@ func testFltrITMigratev2(t *testing.T) {
t.Errorf("Unexpected version returned: %d", vrs[utils.RQF])
}
//check if Filters was migrate correctly
- result, err := fltrMigrator.dmOut.DataManager().GetFilter(filters.Tenant, filters.ID, false, false, utils.NonTransactional)
+ result, err := fltrMigrator.dmOut.DataManager().GetFilter(context.TODO(), filters.Tenant, filters.ID, false, false, utils.NonTransactional)
if err != nil {
t.Fatalf("Error when getting filters %v", err.Error())
}
@@ -446,7 +447,7 @@ func testFltrITMigratev2(t *testing.T) {
t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(expFilters), utils.ToJSON(result))
}
- resultAttr, err := fltrMigrator.dmOut.DataManager().DataDB().GetAttributeProfileDrv(attrProf.Tenant, attrProf.ID)
+ resultAttr, err := fltrMigrator.dmOut.DataManager().DataDB().GetAttributeProfileDrv(context.TODO(), attrProf.Tenant, attrProf.ID)
if err != nil {
t.Fatalf("Error when getting Attributes %v", err.Error())
}
@@ -462,7 +463,7 @@ func testFltrITMigratev2(t *testing.T) {
"*string:*req.Subject:1001": {"ATTR_1": struct{}{}},
}
- if fltridx, err := fltrMigrator.dmOut.DataManager().GetIndexes(
+ if fltridx, err := fltrMigrator.dmOut.DataManager().GetIndexes(context.TODO(),
utils.CacheAttributeFilterIndexes,
utils.ConcatenatedKey(attrProf.Tenant, utils.MetaAny),
"", false, true); err != nil {
@@ -547,7 +548,7 @@ func testFltrITMigratev3(t *testing.T) {
t.Errorf("Unexpected version returned: %d", vrs[utils.RQF])
}
//check if Filters was migrate correctly
- result, err := fltrMigrator.dmOut.DataManager().GetFilter(filters.Tenant, filters.ID, false, false, utils.NonTransactional)
+ result, err := fltrMigrator.dmOut.DataManager().GetFilter(context.TODO(), filters.Tenant, filters.ID, false, false, utils.NonTransactional)
if err != nil {
t.Fatalf("Error when getting filters %v", err.Error())
}
diff --git a/migrator/load_ids_it_test.go b/migrator/load_ids_it_test.go
index a12f8bc42..0b56fdd3c 100644
--- a/migrator/load_ids_it_test.go
+++ b/migrator/load_ids_it_test.go
@@ -25,6 +25,7 @@ import (
"path"
"testing"
+ "github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
@@ -115,7 +116,7 @@ func testLoadIdsITFlush(t *testing.T) {
func testLoadIdsITMigrateAndMove(t *testing.T) {
- err := loadMigrator.dmIN.DataManager().DataDB().SetLoadIDsDrv(map[string]int64{"account": 1}) // this will be deleated
+ err := loadMigrator.dmIN.DataManager().DataDB().SetLoadIDsDrv(context.TODO(), map[string]int64{"account": 1}) // this will be deleated
if err != nil {
t.Error("Error when setting new loadID ", err.Error())
}
diff --git a/migrator/rateprofiles_it_test.go b/migrator/rateprofiles_it_test.go
index 0754fa2f9..51af348ec 100644
--- a/migrator/rateprofiles_it_test.go
+++ b/migrator/rateprofiles_it_test.go
@@ -26,6 +26,7 @@ import (
"reflect"
"testing"
+ "github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
@@ -240,7 +241,7 @@ func testRatePrfITMigrateAndMove(t *testing.T) {
switch ratePrfAction {
case utils.Migrate: //QQ for the moment only one version of rate profiles exists
case utils.Move:
- if err := ratePrfMigrator.dmIN.DataManager().SetRateProfile(rPrf, true); err != nil {
+ if err := ratePrfMigrator.dmIN.DataManager().SetRateProfile(context.TODO(), rPrf, true); err != nil {
t.Error(err)
}
currentVersion := engine.CurrentDataDBVersions()
@@ -249,7 +250,7 @@ func testRatePrfITMigrateAndMove(t *testing.T) {
t.Error("Error when setting version for RatePrf ", err.Error())
}
- _, err = ratePrfMigrator.dmOut.DataManager().GetRateProfile("cgrates.org", "RP1", false, false, utils.NonTransactional)
+ _, err = ratePrfMigrator.dmOut.DataManager().GetRateProfile(context.TODO(), "cgrates.org", "RP1", false, false, utils.NonTransactional)
if err != utils.ErrNotFound {
t.Error(err)
}
@@ -258,14 +259,14 @@ func testRatePrfITMigrateAndMove(t *testing.T) {
if err != nil {
t.Error("Error when migrating RatePrf ", err.Error())
}
- ratePrfult, err := ratePrfMigrator.dmOut.DataManager().GetRateProfile("cgrates.org", "RP1", false, false, utils.NonTransactional)
+ ratePrfult, err := ratePrfMigrator.dmOut.DataManager().GetRateProfile(context.TODO(), "cgrates.org", "RP1", false, false, utils.NonTransactional)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(ratePrfult, rPrf) {
t.Errorf("Expecting: %+v, received: %+v", rPrf, ratePrfult)
}
- ratePrfult, err = ratePrfMigrator.dmIN.DataManager().GetRateProfile("cgrates.org", "RP1", false, false, utils.NonTransactional)
+ ratePrfult, err = ratePrfMigrator.dmIN.DataManager().GetRateProfile(context.TODO(), "cgrates.org", "RP1", false, false, utils.NonTransactional)
if err != utils.ErrNotFound {
t.Error(err)
} else if ratePrfMigrator.stats[utils.RateProfiles] != 1 {