Add & to utils.AttrReloadCacheWithAPIOpts

This commit is contained in:
ionutboangiu
2021-05-27 17:09:07 +03:00
committed by Dan Christian Bogos
parent 21ef078e5c
commit 9daba04d77
24 changed files with 197 additions and 95 deletions

View File

@@ -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 {

View File

@@ -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,
}

View File

@@ -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{