diff --git a/apier/v1/accounts.go b/apier/v1/accounts.go index da0449699..fc561b526 100644 --- a/apier/v1/accounts.go +++ b/apier/v1/accounts.go @@ -144,7 +144,7 @@ func (apierSv1 *APIerSv1) RemoveActionTiming(attrs *AttrRemoveActionTiming, repl return 0, err } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionPlanIDs: {attrs.ActionPlanId}}, }, reply); err != nil { return 0, err @@ -156,7 +156,7 @@ func (apierSv1 *APIerSv1) RemoveActionTiming(attrs *AttrRemoveActionTiming, repl } if len(remAcntAPids) != 0 { if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.AccountActionPlanIDs: remAcntAPids}, }, reply); err != nil { return 0, err @@ -258,7 +258,7 @@ func (apierSv1 *APIerSv1) SetAccount(attr *utils.AttrSetAccount, reply *string) return 0, err } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.AccountActionPlanIDs: {accID}, utils.ActionPlanIDs: apIDs}, }, reply); err != nil { return 0, err @@ -358,7 +358,7 @@ func (apierSv1 *APIerSv1) RemoveAccount(attr *utils.AttrRemoveAccount, reply *st return err } if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.AccountActionPlanIDs: {accID}}, }, reply); err != nil { return diff --git a/apier/v1/api_interfaces.go b/apier/v1/api_interfaces.go index 6460920df..60b2758ce 100644 --- a/apier/v1/api_interfaces.go +++ b/apier/v1/api_interfaces.go @@ -120,7 +120,7 @@ type CacheSv1Interface interface { HasItem(args *utils.ArgsGetCacheItemWithAPIOpts, reply *bool) error GetItemExpiryTime(args *utils.ArgsGetCacheItemWithAPIOpts, reply *time.Time) error RemoveItem(args *utils.ArgsGetCacheItemWithAPIOpts, reply *string) error - RemoveItems(args utils.AttrReloadCacheWithAPIOpts, reply *string) error + RemoveItems(args *utils.AttrReloadCacheWithAPIOpts, reply *string) error Clear(cacheIDs *utils.AttrCacheIDsWithAPIOpts, reply *string) error GetCacheStats(cacheIDs *utils.AttrCacheIDsWithAPIOpts, rply *map[string]*ltcache.CacheStats) error PrecacheStatus(cacheIDs *utils.AttrCacheIDsWithAPIOpts, rply *map[string]string) error diff --git a/apier/v1/apier.go b/apier/v1/apier.go index 1bc19bce9..73f9be199 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -100,7 +100,7 @@ func (apierSv1 *APIerSv1) RemoveDestination(attr *AttrRemoveDestination, reply * return } if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ReverseDestinationIDs: oldDst.Prefixes, utils.DestinationIDs: {dstID}}, }, reply); err != nil { @@ -113,7 +113,7 @@ func (apierSv1 *APIerSv1) RemoveDestination(attr *AttrRemoveDestination, reply * return } if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ReverseDestinationIDs: oldDst.Prefixes, utils.DestinationIDs: {dstID}}, }, reply); err != nil { @@ -186,7 +186,7 @@ func (apierSv1 *APIerSv1) SetDestination(attrs *utils.AttrSetDestination, reply return } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ReverseDestinationIDs: dest.Prefixes, utils.DestinationIDs: {attrs.Id}}, }, reply); err != nil { @@ -217,7 +217,7 @@ func (apierSv1 *APIerSv1) RemoveRatingPlan(ID *string, reply *string) error { return utils.NewErrServerError(err) } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.RatingPlanIDs: {*ID}}, }, reply); err != nil { return err @@ -272,7 +272,7 @@ func (apierSv1 *APIerSv1) LoadDestination(attrs *AttrLoadDestination, reply *str return utils.ErrNotFound } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.DestinationIDs: {attrs.ID}}, }, reply); err != nil { return err @@ -496,7 +496,7 @@ func (apierSv1 *APIerSv1) SetRatingProfile(attrs *utils.AttrSetRatingProfile, re } //CacheReload if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.RatingProfileIDs: {rpfl.Id}}, }, reply); err != nil { return err @@ -647,7 +647,7 @@ func (apierSv1 *APIerSv1) SetActions(attrs *V1AttrSetActions, reply *string) (er } //CacheReload if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionIDs: {attrs.ActionsId}}, }, reply); err != nil { return err @@ -794,7 +794,7 @@ func (apierSv1 *APIerSv1) SetActionPlan(attrs *AttrSetActionPlan, reply *string) return 0, utils.NewErrServerError(err) } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionPlanIDs: {ap.Id}}, }, reply); err != nil { return 0, err @@ -807,7 +807,7 @@ func (apierSv1 *APIerSv1) SetActionPlan(attrs *AttrSetActionPlan, reply *string) if len(prevAccountIDs) != 0 { sl := prevAccountIDs.Slice() if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.AccountActionPlanIDs: sl}, }, reply); err != nil { return 0, err @@ -993,7 +993,7 @@ func (apierSv1 *APIerSv1) RemoveActionPlan(attr *AttrGetActionPlan, reply *strin if len(prevAccountIDs) != 0 { sl := prevAccountIDs.Slice() if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.AccountActionPlanIDs: sl}, }, reply); err != nil { return 0, err @@ -1258,7 +1258,7 @@ func (apierSv1 *APIerSv1) RemoveRatingProfile(attr *AttrRemoveRatingProfile, rep return utils.NewErrServerError(err) } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.RatingProfileIDs: {attr.GetId()}}, }, reply); err != nil { return err @@ -1355,7 +1355,7 @@ func (apierSv1 *APIerSv1) RemoveActions(attr *AttrRemoveActions, reply *string) } //CacheReload if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionIDs: attr.ActionIDs}, }, reply); err != nil { return err diff --git a/apier/v1/caches.go b/apier/v1/caches.go index 822f1650c..923c1fd73 100644 --- a/apier/v1/caches.go +++ b/apier/v1/caches.go @@ -60,7 +60,7 @@ func (chSv1 *CacheSv1) RemoveItem(args *utils.ArgsGetCacheItemWithAPIOpts, } // RemoveItems removes the Items with ID from cache -func (chSv1 *CacheSv1) RemoveItems(args utils.AttrReloadCacheWithAPIOpts, +func (chSv1 *CacheSv1) RemoveItems(args *utils.AttrReloadCacheWithAPIOpts, reply *string) error { return chSv1.cacheS.V1RemoveItems(args, reply) } @@ -102,12 +102,12 @@ func (chSv1 *CacheSv1) RemoveGroup(args *utils.ArgsGetGroupWithAPIOpts, // ReloadCache reloads cache from DB for a prefix or completely func (chSv1 *CacheSv1) ReloadCache(args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { - return chSv1.cacheS.V1ReloadCache(*args, reply) + return chSv1.cacheS.V1ReloadCache(args, reply) } // LoadCache loads cache from DB for a prefix or completely func (chSv1 *CacheSv1) LoadCache(args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { - return chSv1.cacheS.V1LoadCache(*args, reply) + return chSv1.cacheS.V1LoadCache(args, reply) } // Ping used to determinate if component is active diff --git a/apier/v1/caches_it_test.go b/apier/v1/caches_it_test.go index 3fef1e9a7..6485b6fff 100644 --- a/apier/v1/caches_it_test.go +++ b/apier/v1/caches_it_test.go @@ -391,7 +391,7 @@ func testCacheSRemoveItems(t *testing.T) { t.Errorf("Expected: %v , received:%v", true, reply) } var remReply string - if err := chcRPC.Call(utils.CacheSv1RemoveItems, utils.AttrReloadCacheWithAPIOpts{ + if err := chcRPC.Call(utils.CacheSv1RemoveItems, &utils.AttrReloadCacheWithAPIOpts{ APIOpts: make(map[string]interface{}), Tenant: "cgrates.org", ArgsCache: map[string][]string{ diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index 715595897..80bacb0af 100644 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -622,7 +622,7 @@ func (dS *DispatcherCacheSv1) RemoveItem(args *utils.ArgsGetCacheItemWithAPIOpts } // RemoveItems removes the Item with ID from cache -func (dS *DispatcherCacheSv1) RemoveItems(args utils.AttrReloadCacheWithAPIOpts, +func (dS *DispatcherCacheSv1) RemoveItems(args *utils.AttrReloadCacheWithAPIOpts, reply *string) error { return dS.dS.CacheSv1RemoveItems(args, reply) } @@ -664,12 +664,12 @@ func (dS *DispatcherCacheSv1) RemoveGroup(args *utils.ArgsGetGroupWithAPIOpts, // ReloadCache reloads cache from DB for a prefix or completely func (dS *DispatcherCacheSv1) ReloadCache(args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { - return dS.dS.CacheSv1ReloadCache(*args, reply) + return dS.dS.CacheSv1ReloadCache(args, reply) } // LoadCache loads cache from DB for a prefix or completely func (dS *DispatcherCacheSv1) LoadCache(args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { - return dS.dS.CacheSv1LoadCache(*args, reply) + return dS.dS.CacheSv1LoadCache(args, reply) } // ReplicateSet replicate an item diff --git a/apier/v1/dispatcher_it_test.go b/apier/v1/dispatcher_it_test.go index 5aebdfbdd..5ec985591 100644 --- a/apier/v1/dispatcher_it_test.go +++ b/apier/v1/dispatcher_it_test.go @@ -147,11 +147,12 @@ func testDispatcherSSetDispatcherProfile(t *testing.T) { var reply string dispatcherProfile = &DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ - Tenant: "cgrates.org", - ID: "Dsp1", - FilterIDs: []string{"*wrong:inline"}, - Strategy: utils.MetaFirst, - Weight: 20, + Tenant: "cgrates.org", + ID: "Dsp1", + FilterIDs: []string{"*wrong:inline"}, + Subsystems: []string{utils.MetaAny}, + Strategy: utils.MetaFirst, + Weight: 20, }, } @@ -393,10 +394,11 @@ func testDispatcherSKillEngine(t *testing.T) { func testDispatcherSSetDispatcherProfileWithoutTenant(t *testing.T) { dispatcherProfile = &DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ - ID: "Dsp1", - FilterIDs: []string{"*string:~*req.Account:1001"}, - Strategy: utils.MetaFirst, - Weight: 20, + ID: "Dsp1", + FilterIDs: []string{"*string:~*req.Account:1001"}, + Subsystems: []string{utils.MetaAny}, + Strategy: utils.MetaFirst, + Weight: 20, }, } var reply string @@ -502,8 +504,9 @@ func testDispatcherSCacheTestSet(t *testing.T) { var reply string dispatcherProfile = &DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ - Tenant: "cgrates.org", - ID: "DISPATCHER_CACHE", + Tenant: "cgrates.org", + ID: "DISPATCHER_CACHE", + Subsystems: []string{utils.MetaAny}, }, APIOpts: map[string]interface{}{ utils.CacheOpt: utils.MetaNone, diff --git a/apier/v1/full_remote_it_test.go b/apier/v1/full_remote_it_test.go index b83ea93d9..4c35b8247 100644 --- a/apier/v1/full_remote_it_test.go +++ b/apier/v1/full_remote_it_test.go @@ -545,11 +545,12 @@ func testFullRemoteITDispatcher(t *testing.T) { var replySet string dispatcherProfile = &DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ - Tenant: "cgrates.org", - ID: "Dsp1", - FilterIDs: []string{"*string:~*req.Account:1001"}, - Strategy: utils.MetaFirst, - Weight: 20, + Tenant: "cgrates.org", + ID: "Dsp1", + FilterIDs: []string{"*string:~*req.Account:1001"}, + Subsystems: []string{utils.MetaAny}, + Strategy: utils.MetaFirst, + Weight: 20, }, } // add a threshold profile in engine1 and verify it internal diff --git a/apier/v1/libapier.go b/apier/v1/libapier.go index 2f259d425..f83b24cc4 100644 --- a/apier/v1/libapier.go +++ b/apier/v1/libapier.go @@ -78,8 +78,8 @@ func (apierSv1 *APIerSv1) CallCache(cacheopt string, tnt, cacheID, itemID string // composeArgsReload add the ItemID to AttrReloadCache // for a specific CacheID -func (apierSv1 *APIerSv1) composeArgsReload(tnt, cacheID, itemID string, filterIDs *[]string, contexts []string, opts map[string]interface{}) (rpl utils.AttrReloadCacheWithAPIOpts, err error) { - rpl = utils.AttrReloadCacheWithAPIOpts{ +func (apierSv1 *APIerSv1) composeArgsReload(tnt, cacheID, itemID string, filterIDs *[]string, contexts []string, opts map[string]interface{}) (rpl *utils.AttrReloadCacheWithAPIOpts, err error) { + rpl = &utils.AttrReloadCacheWithAPIOpts{ Tenant: tnt, ArgsCache: map[string][]string{ utils.CacheInstanceToArg[cacheID]: {itemID}, @@ -160,7 +160,7 @@ func (apierSv1 *APIerSv1) composeArgsReload(tnt, cacheID, itemID string, filterI func (apierSv1 *APIerSv1) callCacheForRemoveIndexes(cacheopt string, tnt, cacheID string, itemIDs []string, opts map[string]interface{}) (err error) { var reply, method string - var args interface{} = utils.AttrReloadCacheWithAPIOpts{ + var args interface{} = &utils.AttrReloadCacheWithAPIOpts{ Tenant: tnt, ArgsCache: map[string][]string{ utils.CacheInstanceToArg[cacheID]: itemIDs, @@ -191,7 +191,7 @@ func (apierSv1 *APIerSv1) callCacheForRemoveIndexes(cacheopt string, tnt, cacheI func (apierSv1 *APIerSv1) callCacheForComputeIndexes(cacheopt, tnt string, cacheItems map[string][]string, opts map[string]interface{}) (err error) { var reply, method string - var args interface{} = utils.AttrReloadCacheWithAPIOpts{ + var args interface{} = &utils.AttrReloadCacheWithAPIOpts{ Tenant: tnt, ArgsCache: cacheItems, APIOpts: opts, @@ -233,7 +233,7 @@ func (apierSv1 *APIerSv1) callCacheMultiple(cacheopt, tnt, cacheID string, itemI return case utils.MetaReload: method = utils.CacheSv1ReloadCache - args = utils.AttrReloadCacheWithAPIOpts{ + args = &utils.AttrReloadCacheWithAPIOpts{ Tenant: tnt, ArgsCache: map[string][]string{ utils.CacheInstanceToArg[cacheID]: itemIDs, @@ -242,7 +242,7 @@ func (apierSv1 *APIerSv1) callCacheMultiple(cacheopt, tnt, cacheID string, itemI } case utils.MetaLoad: method = utils.CacheSv1LoadCache - args = utils.AttrReloadCacheWithAPIOpts{ + args = &utils.AttrReloadCacheWithAPIOpts{ Tenant: tnt, ArgsCache: map[string][]string{ utils.CacheInstanceToArg[cacheID]: itemIDs, @@ -251,7 +251,7 @@ func (apierSv1 *APIerSv1) callCacheMultiple(cacheopt, tnt, cacheID string, itemI } case utils.MetaRemove: method = utils.CacheSv1RemoveItems - args = utils.AttrReloadCacheWithAPIOpts{ + args = &utils.AttrReloadCacheWithAPIOpts{ Tenant: tnt, ArgsCache: map[string][]string{ utils.CacheInstanceToArg[cacheID]: itemIDs, diff --git a/apier/v1/libapier_test.go b/apier/v1/libapier_test.go index 2d2011e6a..15c53f4ad 100644 --- a/apier/v1/libapier_test.go +++ b/apier/v1/libapier_test.go @@ -30,7 +30,7 @@ import ( func TestComposeArgsReload(t *testing.T) { apv1 := &APIerSv1{} - expArgs := utils.AttrReloadCacheWithAPIOpts{ + expArgs := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: make(map[string]interface{}), Tenant: "cgrates.org", ArgsCache: map[string][]string{ @@ -66,7 +66,7 @@ func TestComposeArgsReload(t *testing.T) { t.Errorf("Expected %s ,received: %s", utils.ToJSON(expArgs), utils.ToJSON(rply)) } - expArgs = utils.AttrReloadCacheWithAPIOpts{ + expArgs = &utils.AttrReloadCacheWithAPIOpts{ APIOpts: make(map[string]interface{}), Tenant: "cgrates.org", ArgsCache: map[string][]string{ @@ -150,7 +150,7 @@ func TestCallCache(t *testing.T) { exp = &rpcRequest{ Method: utils.CacheSv1ReloadCache, - Params: utils.AttrReloadCacheWithAPIOpts{ + Params: &utils.AttrReloadCacheWithAPIOpts{ APIOpts: make(map[string]interface{}), Tenant: "cgrates.org", ArgsCache: map[string][]string{ diff --git a/apier/v1/remote_it_test.go b/apier/v1/remote_it_test.go index 4496b6d06..e03c74c50 100644 --- a/apier/v1/remote_it_test.go +++ b/apier/v1/remote_it_test.go @@ -600,11 +600,12 @@ func testInternalRemoteITGetDispatcherProfile(t *testing.T) { dispatcherProfile = &DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ - Tenant: "cgrates.org", - ID: "Dsp1", - FilterIDs: []string{"*string:~*req.Account:1001"}, - Strategy: utils.MetaFirst, - Weight: 20, + Tenant: "cgrates.org", + ID: "Dsp1", + FilterIDs: []string{"*string:~*req.Account:1001"}, + Subsystems: []string{utils.MetaAny}, + Strategy: utils.MetaFirst, + Weight: 20, }, } diff --git a/apier/v1/replicate_it_test.go b/apier/v1/replicate_it_test.go index da39f0949..e36e8ccab 100644 --- a/apier/v1/replicate_it_test.go +++ b/apier/v1/replicate_it_test.go @@ -502,11 +502,12 @@ func testInternalReplicateITDispatcherProfile(t *testing.T) { // set dispatcherProfile = &DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ - Tenant: "cgrates.org", - ID: "Dsp1", - FilterIDs: []string{"*string:~*req.Account:1001"}, - Strategy: utils.MetaFirst, - Weight: 20, + Tenant: "cgrates.org", + ID: "Dsp1", + FilterIDs: []string{"*string:~*req.Account:1001"}, + Subsystems: []string{utils.MetaAny}, + Strategy: utils.MetaFirst, + Weight: 20, }, } if err := internalRPC.Call(utils.APIerSv1SetDispatcherProfile, dispatcherProfile, diff --git a/apier/v1/triggers.go b/apier/v1/triggers.go index 4eb300d3b..b39228b0c 100644 --- a/apier/v1/triggers.go +++ b/apier/v1/triggers.go @@ -429,7 +429,7 @@ func (apierSv1 *APIerSv1) RemoveActionTrigger(attr *AttrRemoveActionTrigger, rep } // CacheReload if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionTriggerIDs: {attr.GroupID}}, }, reply); err != nil { return @@ -479,7 +479,7 @@ func (apierSv1 *APIerSv1) SetActionTrigger(attr *AttrSetActionTrigger, reply *st } // CacheReload if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionTriggerIDs: {attr.GroupID}}, }, reply); err != nil { return diff --git a/apier/v2/accounts.go b/apier/v2/accounts.go index 97c1ae549..80f2aa165 100644 --- a/apier/v2/accounts.go +++ b/apier/v2/accounts.go @@ -218,7 +218,7 @@ func (apiv2 *APIerSv2) SetAccount(attr *AttrSetAccount, reply *string) error { return 0, err } return 0, apiv2.ConnMgr.Call(apiv2.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.AccountActionPlanIDs: {accID}, utils.ActionPlanIDs: apIDs}, }, reply) }, config.CgrConfig().GeneralCfg().LockingTimeout, utils.ActionPlanPrefix) diff --git a/apier/v2/apier.go b/apier/v2/apier.go index 61988df74..148985154 100644 --- a/apier/v2/apier.go +++ b/apier/v2/apier.go @@ -355,7 +355,7 @@ func (apiv2 *APIerSv2) SetActions(attrs *utils.AttrSetActions, reply *string) er } //CacheReload if err := apiv2.ConnMgr.Call(apiv2.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionIDs: {attrs.ActionsId}}, }, reply); err != nil { return err diff --git a/data/conf/samples/cache_replicate/fltr_update_e1_mongo/cgrates.json b/data/conf/samples/cache_replicate/fltr_update_e1_mongo/cgrates.json new file mode 100644 index 000000000..1c21d185e --- /dev/null +++ b/data/conf/samples/cache_replicate/fltr_update_e1_mongo/cgrates.json @@ -0,0 +1,51 @@ +{ + // CGRateS Configuration file + // Used in general_tests/ + + + "general": { + "node_id": "fltr_update_e1_mongo", + "log_level": 7 + }, + + + "listen": { + "rpc_json": ":22012", + "rpc_gob": ":22013", + "http": ":22080", + }, + + + "data_db": { + "db_type": "mongo", + "db_name": "10", + "db_port": 27017, + }, + + + "stor_db": { + "db_type": "mongo", + "db_name": "cgrates", + "db_port": 27017, + }, + + + + "rpc_conns": { + "cache_conn": { + "strategy": "*broadcast_sync", + "conns": [{"address": "127.0.0.1:22012", "transport": "*json"}, {"address": "127.0.0.1:2012", "transport": "*json"}], + }, + }, + + "attributes": { + "enabled": true + }, + + "apiers": { + "enabled": true, + "caches_conns":["cache_conn"], + }, + + } + \ No newline at end of file diff --git a/data/conf/samples/cache_replicate/fltr_update_e1_mysql/cgrates.json b/data/conf/samples/cache_replicate/fltr_update_e1_mysql/cgrates.json new file mode 100644 index 000000000..4b719838b --- /dev/null +++ b/data/conf/samples/cache_replicate/fltr_update_e1_mysql/cgrates.json @@ -0,0 +1,45 @@ +{ + // CGRateS Configuration file + // + + + "general": { + "node_id": "fltr_update_e1_mysql", + "log_level": 7 + }, + + + "listen": { + "rpc_json": ":22012", + "rpc_gob": ":22013", + "http": ":22080", + }, + + "data_db": { // database used to store runtime data (eg: accounts, cdr stats) + "db_type": "redis", // data_db type: + "db_port": 6379, // data_db port to reach the database + "db_name": "10", // data_db database name to connect to + }, + + "stor_db": { + "db_password": "CGRateS.org", + }, + + "rpc_conns": { + "cache_conn": { + "strategy": "*broadcast_sync", + "conns": [{"address": "127.0.0.1:22012", "transport":"*json"},{"address": "127.0.0.1:2012", "transport": "*json"}], + }, + }, + + "attributes": { + "enabled": true + }, + + "apiers": { + "enabled": true, + "caches_conns":["cache_conn"], + }, + + } + \ No newline at end of file diff --git a/dispatchers/caches.go b/dispatchers/caches.go index 21f156dfd..8a7c1677c 100644 --- a/dispatchers/caches.go +++ b/dispatchers/caches.go @@ -124,7 +124,7 @@ func (dS *DispatcherService) CacheSv1RemoveItem(args *utils.ArgsGetCacheItemWith } // CacheSv1RemoveItems removes the Item with ID from cache -func (dS *DispatcherService) CacheSv1RemoveItems(args utils.AttrReloadCacheWithAPIOpts, +func (dS *DispatcherService) CacheSv1RemoveItems(args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { @@ -255,7 +255,7 @@ func (dS *DispatcherService) CacheSv1RemoveGroup(args *utils.ArgsGetGroupWithAPI } // CacheSv1ReloadCache reloads cache from DB for a prefix or completely -func (dS *DispatcherService) CacheSv1ReloadCache(args utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { +func (dS *DispatcherService) CacheSv1ReloadCache(args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { tnt = args.Tenant @@ -273,7 +273,7 @@ func (dS *DispatcherService) CacheSv1ReloadCache(args utils.AttrReloadCacheWithA } // CacheSv1LoadCache loads cache from DB for a prefix or completely -func (dS *DispatcherService) CacheSv1LoadCache(args utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { +func (dS *DispatcherService) CacheSv1LoadCache(args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { tnt = args.Tenant diff --git a/dispatchers/caches_it_test.go b/dispatchers/caches_it_test.go index 242f0c781..5af3b9337 100644 --- a/dispatchers/caches_it_test.go +++ b/dispatchers/caches_it_test.go @@ -115,7 +115,7 @@ func testDspChcLoadAfterFolder(t *testing.T) { } reply := "" // Simple test that command is executed without errors - if err := dispEngine.RPC.Call(utils.CacheSv1LoadCache, utils.AttrReloadCacheWithAPIOpts{ + if err := dispEngine.RPC.Call(utils.CacheSv1LoadCache, &utils.AttrReloadCacheWithAPIOpts{ APIOpts: map[string]interface{}{ utils.OptsAPIKey: "chc12345", }, diff --git a/dispatchers/caches_test.go b/dispatchers/caches_test.go index a33e31f4c..c10961ca6 100644 --- a/dispatchers/caches_test.go +++ b/dispatchers/caches_test.go @@ -187,7 +187,7 @@ func TestDspCacheSv1RemoveItemsError(t *testing.T) { cgrCfg := config.NewDefaultCGRConfig() dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"} - CGREvent := utils.AttrReloadCacheWithAPIOpts{} + CGREvent := &utils.AttrReloadCacheWithAPIOpts{} var reply *string result := dspSrv.CacheSv1RemoveItems(CGREvent, reply) expected := "MANDATORY_IE_MISSING: [ApiKey]" @@ -199,7 +199,7 @@ func TestDspCacheSv1RemoveItemsError(t *testing.T) { func TestDspCacheSv1RemoveItemsArgsNil(t *testing.T) { cgrCfg := config.NewDefaultCGRConfig() dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) - CGREvent := utils.AttrReloadCacheWithAPIOpts{ + CGREvent := &utils.AttrReloadCacheWithAPIOpts{ Tenant: "tenant", } var reply *string @@ -376,7 +376,7 @@ func TestDspCacheSv1ReloadCacheError(t *testing.T) { cgrCfg := config.NewDefaultCGRConfig() dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"} - CGREvent := utils.AttrReloadCacheWithAPIOpts{} + CGREvent := &utils.AttrReloadCacheWithAPIOpts{} var reply *string result := dspSrv.CacheSv1ReloadCache(CGREvent, reply) expected := "MANDATORY_IE_MISSING: [ApiKey]" @@ -388,7 +388,7 @@ func TestDspCacheSv1ReloadCacheError(t *testing.T) { func TestDspCacheSv1ReloadCacheNil(t *testing.T) { cgrCfg := config.NewDefaultCGRConfig() dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) - CGREvent := utils.AttrReloadCacheWithAPIOpts{ + CGREvent := &utils.AttrReloadCacheWithAPIOpts{ Tenant: "tenant", } var reply *string @@ -403,7 +403,7 @@ func TestDspCacheSv1LoadCacheError(t *testing.T) { cgrCfg := config.NewDefaultCGRConfig() dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) cgrCfg.DispatcherSCfg().AttributeSConns = []string{"test"} - CGREvent := utils.AttrReloadCacheWithAPIOpts{} + CGREvent := &utils.AttrReloadCacheWithAPIOpts{} var reply *string result := dspSrv.CacheSv1LoadCache(CGREvent, reply) expected := "MANDATORY_IE_MISSING: [ApiKey]" @@ -415,7 +415,7 @@ func TestDspCacheSv1LoadCacheError(t *testing.T) { func TestDspCacheSv1LoadCacheNil(t *testing.T) { cgrCfg := config.NewDefaultCGRConfig() dspSrv := NewDispatcherService(nil, cgrCfg, nil, nil) - CGREvent := utils.AttrReloadCacheWithAPIOpts{ + CGREvent := &utils.AttrReloadCacheWithAPIOpts{ Tenant: "tenant", } var reply *string diff --git a/engine/caches.go b/engine/caches.go index 28618e58f..24718bd94 100644 --- a/engine/caches.go +++ b/engine/caches.go @@ -291,7 +291,7 @@ func (chS *CacheS) V1RemoveItem(args *utils.ArgsGetCacheItemWithAPIOpts, return } -func (chS *CacheS) V1RemoveItems(args utils.AttrReloadCacheWithAPIOpts, +func (chS *CacheS) V1RemoveItems(args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { for key, ids := range args.ArgsCache { if cacheID, has := utils.ArgCacheToInstance[key]; has { @@ -360,15 +360,15 @@ func (chS *CacheS) V1RemoveGroup(args *utils.ArgsGetGroupWithAPIOpts, return } -func (chS *CacheS) V1ReloadCache(attrs utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { +func (chS *CacheS) V1ReloadCache(attrs *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { return chS.cacheDataFromDB(attrs, reply, true) } -func (chS *CacheS) V1LoadCache(attrs utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { +func (chS *CacheS) V1LoadCache(attrs *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { return chS.cacheDataFromDB(attrs, reply, false) } -func (chS *CacheS) cacheDataFromDB(attrs utils.AttrReloadCacheWithAPIOpts, reply *string, mustBeCached bool) (err error) { +func (chS *CacheS) cacheDataFromDB(attrs *utils.AttrReloadCacheWithAPIOpts, reply *string, mustBeCached bool) (err error) { for key, ids := range attrs.ArgsCache { if prfx, has := utils.ArgCacheToPrefix[key]; has { if err = chS.dm.CacheDataFromDB(prfx, ids, mustBeCached); err != nil { diff --git a/engine/tpreader.go b/engine/tpreader.go index 51ecd960d..58b55dfbb 100644 --- a/engine/tpreader.go +++ b/engine/tpreader.go @@ -784,7 +784,7 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *utils.TPAccountActions) } var reply string if err := connMgr.Call(tpr.cacheConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{ utils.AccountActionPlanIDs: {id}, utils.ActionPlanIDs: {accountAction.ActionPlanId}, @@ -893,7 +893,7 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *utils.TPAccountActions) } var reply string if err := connMgr.Call(tpr.cacheConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{ utils.ActionTriggerIDs: {accountAction.ActionTriggersId}, }, @@ -1011,7 +1011,7 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *utils.TPAccountActions) } var reply string if err := connMgr.Call(tpr.cacheConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ + utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{ utils.ActionIDs: {k}, }, @@ -2331,7 +2331,7 @@ func CallCache(connMgr *ConnManager, cacheConns []string, caching string, args m } } var method, reply string - var cacheArgs interface{} = utils.AttrReloadCacheWithAPIOpts{ + var cacheArgs interface{} = &utils.AttrReloadCacheWithAPIOpts{ APIOpts: opts, ArgsCache: args, } diff --git a/engine/tpreader_test.go b/engine/tpreader_test.go index fa7f94669..b9a726a9a 100644 --- a/engine/tpreader_test.go +++ b/engine/tpreader_test.go @@ -82,7 +82,7 @@ func TestCallCacheReloadCacheFirstCallErr(t *testing.T) { ccM := &ccMock{ calls: map[string]func(args interface{}, reply interface{}) error{ utils.CacheSv1ReloadCache: func(args, reply interface{}) error { - expArgs := utils.AttrReloadCacheWithAPIOpts{ + expArgs := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: map[string]interface{}{ utils.Subsys: utils.MetaChargers, }, @@ -229,7 +229,7 @@ func TestCallCacheLoadCache(t *testing.T) { ccM := &ccMock{ calls: map[string]func(args interface{}, reply interface{}) error{ utils.CacheSv1LoadCache: func(args, reply interface{}) error { - expArgs := utils.AttrReloadCacheWithAPIOpts{ + expArgs := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: map[string]interface{}{ utils.Subsys: utils.MetaChargers, }, @@ -299,7 +299,7 @@ func TestCallCacheRemoveItems(t *testing.T) { ccM := &ccMock{ calls: map[string]func(args interface{}, reply interface{}) error{ utils.CacheSv1RemoveItems: func(args, reply interface{}) error { - expArgs := utils.AttrReloadCacheWithAPIOpts{ + expArgs := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: map[string]interface{}{ utils.Subsys: utils.MetaChargers, }, @@ -939,7 +939,7 @@ func TestGetLoadedIdsError(t *testing.T) { func TestReloadCache(t *testing.T) { data := NewInternalDB(nil, nil, false) cfg := config.NewDefaultCGRConfig() - argExpect := utils.AttrReloadCacheWithAPIOpts{ + argExpect := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: map[string]interface{}{}, Tenant: "", ArgsCache: map[string][]string{ diff --git a/loaders/loader_test.go b/loaders/loader_test.go index efb2aa013..0d216b85e 100644 --- a/loaders/loader_test.go +++ b/loaders/loader_test.go @@ -3172,7 +3172,7 @@ func TestStoreLoadedDataAttributes(t *testing.T) { data := engine.NewInternalDB(nil, nil, false) cfg := config.NewDefaultCGRConfig() - argExpect := utils.AttrReloadCacheWithAPIOpts{ + argExpect := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: nil, Tenant: "", ArgsCache: map[string][]string{ @@ -3223,7 +3223,7 @@ func TestStoreLoadedDataResources(t *testing.T) { engine.Cache.Clear(nil) data := engine.NewInternalDB(nil, nil, false) cfg := config.NewDefaultCGRConfig() - argExpect := utils.AttrReloadCacheWithAPIOpts{ + argExpect := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: nil, Tenant: "", ArgsCache: map[string][]string{ @@ -3279,7 +3279,7 @@ func TestStoreLoadedDataFilters(t *testing.T) { engine.Cache.Clear(nil) data := engine.NewInternalDB(nil, nil, false) cfg := config.NewDefaultCGRConfig() - argExpect := utils.AttrReloadCacheWithAPIOpts{ + argExpect := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: nil, Tenant: "", ArgsCache: map[string][]string{ @@ -3330,7 +3330,7 @@ func TestStoreLoadedDataStats(t *testing.T) { engine.Cache.Clear(nil) data := engine.NewInternalDB(nil, nil, false) cfg := config.NewDefaultCGRConfig() - argExpect := utils.AttrReloadCacheWithAPIOpts{ + argExpect := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: nil, Tenant: "", ArgsCache: map[string][]string{ @@ -3386,7 +3386,7 @@ func TestStoreLoadedDataThresholds(t *testing.T) { engine.Cache.Clear(nil) data := engine.NewInternalDB(nil, nil, false) cfg := config.NewDefaultCGRConfig() - argExpect := utils.AttrReloadCacheWithAPIOpts{ + argExpect := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: nil, Tenant: "", ArgsCache: map[string][]string{ @@ -3442,7 +3442,7 @@ func TestStoreLoadedDataRoutes(t *testing.T) { engine.Cache.Clear(nil) data := engine.NewInternalDB(nil, nil, false) cfg := config.NewDefaultCGRConfig() - argExpect := utils.AttrReloadCacheWithAPIOpts{ + argExpect := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: nil, Tenant: "", ArgsCache: map[string][]string{ @@ -3493,7 +3493,7 @@ func TestStoreLoadedDataChargers(t *testing.T) { engine.Cache.Clear(nil) data := engine.NewInternalDB(nil, nil, false) cfg := config.NewDefaultCGRConfig() - argExpect := utils.AttrReloadCacheWithAPIOpts{ + argExpect := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: nil, Tenant: "", ArgsCache: map[string][]string{ @@ -3544,7 +3544,7 @@ func TestStoreLoadedDataDispatchers(t *testing.T) { engine.Cache.Clear(nil) data := engine.NewInternalDB(nil, nil, false) cfg := config.NewDefaultCGRConfig() - argExpect := utils.AttrReloadCacheWithAPIOpts{ + argExpect := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: nil, Tenant: "", ArgsCache: map[string][]string{ @@ -3595,7 +3595,7 @@ func TestStoreLoadedDataDispatcherHosts(t *testing.T) { engine.Cache.Clear(nil) data := engine.NewInternalDB(nil, nil, false) cfg := config.NewDefaultCGRConfig() - argExpect := utils.AttrReloadCacheWithAPIOpts{ + argExpect := &utils.AttrReloadCacheWithAPIOpts{ APIOpts: nil, Tenant: "", ArgsCache: map[string][]string{