mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-19 22:28:45 +05:00
Add & to utils.AttrReloadCacheWithAPIOpts 1.0
This commit is contained in:
committed by
Dan Christian Bogos
parent
3d8802af99
commit
e7061d9ba4
@@ -62,7 +62,7 @@ func (chSv1 *CacheSv1) RemoveItem(_ *context.Context, args *utils.ArgsGetCacheIt
|
||||
}
|
||||
|
||||
// RemoveItems removes the Items with ID from cache
|
||||
func (chSv1 *CacheSv1) RemoveItems(_ *context.Context, args utils.AttrReloadCacheWithAPIOpts,
|
||||
func (chSv1 *CacheSv1) RemoveItems(_ *context.Context, args *utils.AttrReloadCacheWithAPIOpts,
|
||||
reply *string) error {
|
||||
return chSv1.cacheS.V1RemoveItems(args, reply)
|
||||
}
|
||||
@@ -104,12 +104,12 @@ func (chSv1 *CacheSv1) RemoveGroup(args *utils.ArgsGetGroupWithAPIOpts, //
|
||||
|
||||
// ReloadCache reloads cache from DB for a prefix or completely
|
||||
func (chSv1 *CacheSv1) ReloadCache(ctx *context.Context, args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) {
|
||||
return chSv1.cacheS.V1ReloadCache(ctx, *args, reply)
|
||||
return chSv1.cacheS.V1ReloadCache(ctx, args, reply)
|
||||
}
|
||||
|
||||
// LoadCache loads cache from DB for a prefix or completely
|
||||
func (chSv1 *CacheSv1) LoadCache(ctx *context.Context, args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) {
|
||||
return chSv1.cacheS.V1LoadCache(ctx, *args, reply)
|
||||
return chSv1.cacheS.V1LoadCache(ctx, args, reply)
|
||||
}
|
||||
|
||||
// ReplicateSet replicate an item
|
||||
|
||||
@@ -371,7 +371,7 @@ func testCacheSRemoveItemsAndReloadCache(t *testing.T) {
|
||||
}
|
||||
|
||||
//remove all items
|
||||
argsRemove := utils.AttrReloadCacheWithAPIOpts{
|
||||
argsRemove := &utils.AttrReloadCacheWithAPIOpts{
|
||||
ArgsCache: map[string][]string{
|
||||
utils.AttributeProfileIDs: {"cgrates.org:TEST_ATTRIBUTES_IT_TEST"},
|
||||
},
|
||||
|
||||
@@ -133,7 +133,7 @@ func TestCacheSetAndRemoveItems(t *testing.T) {
|
||||
ch.SetWithoutReplicate(utils.CacheAttributeProfiles, "cgrates.org:TestCacheSetAndRemoveItems3", nil, nil, true, utils.NonTransactional)
|
||||
cache := NewCacheSv1(ch)
|
||||
|
||||
argsRemItm := utils.AttrReloadCacheWithAPIOpts{
|
||||
argsRemItm := &utils.AttrReloadCacheWithAPIOpts{
|
||||
ArgsCache: map[string][]string{
|
||||
utils.AttributeProfileIDs: {"cgrates.org:TestCacheSetAndRemoveItems1",
|
||||
"cgrates.org:TestCacheSetAndRemoveItems2", "cgrates.org:TestCacheSetAndRemoveItems3"},
|
||||
|
||||
@@ -235,7 +235,7 @@ func (apierSv1 *AdminS) callCacheMultiple(cacheopt, tnt, cacheID string, itemIDs
|
||||
return
|
||||
case utils.MetaReload:
|
||||
method = utils.CacheSv1ReloadCache
|
||||
args = utils.AttrReloadCacheWithAPIOpts{
|
||||
args = &utils.AttrReloadCacheWithAPIOpts{
|
||||
Tenant: tnt,
|
||||
ArgsCache: map[string][]string{
|
||||
utils.CacheInstanceToArg[cacheID]: itemIDs,
|
||||
@@ -244,7 +244,7 @@ func (apierSv1 *AdminS) callCacheMultiple(cacheopt, tnt, cacheID string, itemIDs
|
||||
}
|
||||
case utils.MetaLoad:
|
||||
method = utils.CacheSv1LoadCache
|
||||
args = utils.AttrReloadCacheWithAPIOpts{
|
||||
args = &utils.AttrReloadCacheWithAPIOpts{
|
||||
Tenant: tnt,
|
||||
ArgsCache: map[string][]string{
|
||||
utils.CacheInstanceToArg[cacheID]: itemIDs,
|
||||
@@ -253,7 +253,7 @@ func (apierSv1 *AdminS) callCacheMultiple(cacheopt, tnt, cacheID string, itemIDs
|
||||
}
|
||||
case utils.MetaRemove:
|
||||
method = utils.CacheSv1RemoveItems
|
||||
args = utils.AttrReloadCacheWithAPIOpts{
|
||||
args = &utils.AttrReloadCacheWithAPIOpts{
|
||||
Tenant: tnt,
|
||||
ArgsCache: map[string][]string{
|
||||
utils.CacheInstanceToArg[cacheID]: itemIDs,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -112,7 +112,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",
|
||||
},
|
||||
|
||||
@@ -185,7 +185,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]"
|
||||
@@ -197,7 +197,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
|
||||
@@ -374,7 +374,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]"
|
||||
@@ -386,7 +386,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
|
||||
@@ -401,7 +401,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]"
|
||||
@@ -413,7 +413,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
|
||||
|
||||
@@ -287,7 +287,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 {
|
||||
@@ -356,15 +356,15 @@ func (chS *CacheS) V1RemoveGroup(args *utils.ArgsGetGroupWithAPIOpts,
|
||||
return
|
||||
}
|
||||
|
||||
func (chS *CacheS) V1ReloadCache(ctx *context.Context, attrs utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) {
|
||||
func (chS *CacheS) V1ReloadCache(ctx *context.Context, attrs *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) {
|
||||
return chS.cacheDataFromDB(ctx, attrs, reply, true)
|
||||
}
|
||||
|
||||
func (chS *CacheS) V1LoadCache(ctx *context.Context, attrs utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) {
|
||||
func (chS *CacheS) V1LoadCache(ctx *context.Context, attrs *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) {
|
||||
return chS.cacheDataFromDB(ctx, attrs, reply, false)
|
||||
}
|
||||
|
||||
func (chS *CacheS) cacheDataFromDB(ctx *context.Context, attrs utils.AttrReloadCacheWithAPIOpts, reply *string, mustBeCached bool) (err error) {
|
||||
func (chS *CacheS) cacheDataFromDB(ctx *context.Context, 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(ctx, prfx, ids, mustBeCached); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user