diff --git a/apier/v1/apier.go b/apier/v1/apier.go
index b7b6ed123..ccba7d288 100644
--- a/apier/v1/apier.go
+++ b/apier/v1/apier.go
@@ -271,10 +271,11 @@ func (self *ApierV1) LoadSharedGroup(attrs AttrLoadSharedGroup, reply *string) e
}
type AttrLoadTpFromStorDb struct {
- TPid string
- FlushDb bool // Flush dataDB before loading
- DryRun bool // Only simulate, no write
- Validate bool // Run structural checks
+ TPid string
+ FlushDb bool // Flush dataDB before loading
+ DryRun bool // Only simulate, no write
+ Validate bool // Run structural checks
+ ArgDispatcher *utils.ArgDispatcher
}
// Loads complete data in a TP from storDb
@@ -303,7 +304,7 @@ func (self *ApierV1) LoadTariffPlanFromStorDb(attrs AttrLoadTpFromStorDb, reply
}
// reload cache
utils.Logger.Info("ApierV1.LoadTariffPlanFromStorDb, reloading cache.")
- if err := dbReader.ReloadCache(attrs.FlushDb, true); err != nil {
+ if err := dbReader.ReloadCache(attrs.FlushDb, true, attrs.ArgDispatcher); err != nil {
return utils.NewErrServerError(err)
}
@@ -804,7 +805,7 @@ func (self *ApierV1) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
}
// reload cache
utils.Logger.Info("ApierV1.LoadTariffPlanFromFolder, reloading cache.")
- if err := loader.ReloadCache(attrs.FlushDb, true); err != nil {
+ if err := loader.ReloadCache(attrs.FlushDb, true, attrs.ArgDispatcher); err != nil {
return utils.NewErrServerError(err)
}
*reply = utils.OK
@@ -1058,25 +1059,29 @@ func (v1 *ApierV1) ReplayFailedPosts(args ArgsReplyFailedPosts, reply *string) (
// CallCache caching the item based on cacheopt
// visible in ApierV2
-func (v1 *ApierV1) CallCache(cacheOpt string, args engine.ArgsGetCacheItem) (err error) {
+func (v1 *ApierV1) CallCache(cacheOpt string, args utils.ArgsGetCacheItem) (err error) {
var reply string
switch cacheOpt {
case utils.META_NONE:
return
case utils.MetaReload:
- if err = v1.CacheS.Call(utils.CacheSv1ReloadCache, composeArgsReload(args), &reply); err != nil {
+ if err = v1.CacheS.Call(utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
+ AttrReloadCache: composeArgsReload(args)}, &reply); err != nil {
return err
}
case utils.MetaLoad:
- if err = v1.CacheS.Call(utils.CacheSv1LoadCache, composeArgsReload(args), &reply); err != nil {
+ if err = v1.CacheS.Call(utils.CacheSv1LoadCache, utils.AttrReloadCacheWithArgDispatcher{
+ AttrReloadCache: composeArgsReload(args)}, &reply); err != nil {
return err
}
case utils.MetaRemove:
- if err = v1.CacheS.Call(utils.CacheSv1RemoveItem, &args, &reply); err != nil {
+ if err = v1.CacheS.Call(utils.CacheSv1RemoveItem,
+ &utils.ArgsGetCacheItemWithArgDispatcher{ArgsGetCacheItem: args}, &reply); err != nil {
return err
}
case utils.MetaClear:
- if err = v1.CacheS.Call(utils.CacheSv1FlushCache, composeArgsReload(args), &reply); err != nil {
+ if err = v1.CacheS.Call(utils.CacheSv1FlushCache, utils.AttrReloadCacheWithArgDispatcher{
+ AttrReloadCache: composeArgsReload(args)}, &reply); err != nil {
return err
}
}
diff --git a/apier/v1/attributes.go b/apier/v1/attributes.go
index f979c5e30..c48207a07 100644
--- a/apier/v1/attributes.go
+++ b/apier/v1/attributes.go
@@ -91,7 +91,7 @@ func (apierV1 *ApierV1) SetAttributeProfile(alsWrp *AttributeWithCache, reply *s
if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheAttributeProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
- args := engine.ArgsGetCacheItem{
+ args := utils.ArgsGetCacheItem{
CacheID: utils.CacheAttributeProfiles,
ItemID: alsWrp.TenantID(),
}
@@ -115,7 +115,7 @@ func (apierV1 *ApierV1) RemoveAttributeProfile(arg *utils.TenantIDWithCache, rep
if err := apierV1.DataManager.SetLoadIDs(map[string]int64{utils.CacheAttributeProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
- args := engine.ArgsGetCacheItem{
+ args := utils.ArgsGetCacheItem{
CacheID: utils.CacheAttributeProfiles,
ItemID: utils.ConcatenatedKey(arg.Tenant, arg.ID),
}
diff --git a/apier/v1/attributes_it_test.go b/apier/v1/attributes_it_test.go
index b09eabc4e..da6ce3fab 100644
--- a/apier/v1/attributes_it_test.go
+++ b/apier/v1/attributes_it_test.go
@@ -1219,7 +1219,7 @@ func testAttributeSCachingMetaNone(t *testing.T) {
t.Error("Unexpected reply returned", result)
}
var reply bool
- argsCache := engine.ArgsGetCacheItem{
+ argsCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheAttributeProfiles,
ItemID: "cgrates.org:ATTR_1",
}
@@ -1230,7 +1230,7 @@ func testAttributeSCachingMetaNone(t *testing.T) {
}
var rcvKeys []string
- argsCache2 := engine.ArgsGetCacheItemIDs{
+ argsCache2 := utils.ArgsGetCacheItemIDs{
CacheID: utils.CacheAttributeProfiles,
}
if err := attrSRPC.Call(utils.CacheSv1GetItemIDs, argsCache2, &rcvKeys); err == nil ||
@@ -1278,7 +1278,7 @@ func testAttributeSCachingMetaLoad(t *testing.T) {
t.Error("Unexpected reply returned", result)
}
var reply bool
- argsCache := engine.ArgsGetCacheItem{
+ argsCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheAttributeProfiles,
ItemID: "cgrates.org:ATTR_1",
}
@@ -1290,7 +1290,7 @@ func testAttributeSCachingMetaLoad(t *testing.T) {
var rcvKeys []string
expectedIDs := []string{"cgrates.org:ATTR_1"}
- argsCache2 := engine.ArgsGetCacheItemIDs{
+ argsCache2 := utils.ArgsGetCacheItemIDs{
CacheID: utils.CacheAttributeProfiles,
}
if err := attrSRPC.Call(utils.CacheSv1GetItemIDs, argsCache2, &rcvKeys); err != nil {
@@ -1317,7 +1317,7 @@ func testAttributeSCachingMetaLoad(t *testing.T) {
t.Error("Unexpected reply returned", resp)
}
- argsCache = engine.ArgsGetCacheItem{
+ argsCache = utils.ArgsGetCacheItem{
CacheID: utils.CacheAttributeProfiles,
ItemID: "cgrates.org:ATTR_1",
}
@@ -1370,7 +1370,7 @@ func testAttributeSCachingMetaReload1(t *testing.T) {
t.Error("Unexpected reply returned", result)
}
var reply bool
- argsCache := engine.ArgsGetCacheItem{
+ argsCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheAttributeProfiles,
ItemID: "cgrates.org:ATTR_1",
}
@@ -1381,7 +1381,7 @@ func testAttributeSCachingMetaReload1(t *testing.T) {
}
var rcvKeys []string
- argsCache2 := engine.ArgsGetCacheItemIDs{
+ argsCache2 := utils.ArgsGetCacheItemIDs{
CacheID: utils.CacheAttributeProfiles,
}
if err := attrSRPC.Call(utils.CacheSv1GetItemIDs, argsCache2, &rcvKeys); err == nil ||
@@ -1508,7 +1508,7 @@ func testAttributeSCachingMetaRemove(t *testing.T) {
t.Error("Unexpected reply returned", result)
}
var reply bool
- argsCache := engine.ArgsGetCacheItem{
+ argsCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheAttributeProfiles,
ItemID: "cgrates.org:ATTR_1",
}
@@ -1520,7 +1520,7 @@ func testAttributeSCachingMetaRemove(t *testing.T) {
var rcvKeys []string
expectedIDs := []string{"cgrates.org:ATTR_1"}
- argsCache2 := engine.ArgsGetCacheItemIDs{
+ argsCache2 := utils.ArgsGetCacheItemIDs{
CacheID: utils.CacheAttributeProfiles,
}
if err := attrSRPC.Call(utils.CacheSv1GetItemIDs, argsCache2, &rcvKeys); err != nil {
diff --git a/apier/v1/caches.go b/apier/v1/caches.go
index ad885944b..4a6033094 100644
--- a/apier/v1/caches.go
+++ b/apier/v1/caches.go
@@ -21,7 +21,6 @@ package v1
import (
"time"
- "github.com/cgrates/cgrates/dispatchers"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
"github.com/cgrates/ltcache"
@@ -37,77 +36,77 @@ type CacheSv1 struct {
}
// GetItemIDs returns the IDs for cacheID with given prefix
-func (chSv1 *CacheSv1) GetItemIDs(args *dispatchers.ArgsGetCacheItemIDsWithApiKey,
+func (chSv1 *CacheSv1) GetItemIDs(args *utils.ArgsGetCacheItemIDsWithArgDispatcher,
reply *[]string) error {
- return chSv1.cacheS.V1GetItemIDs(&args.ArgsGetCacheItemIDs, reply)
+ return chSv1.cacheS.V1GetItemIDs(args, reply)
}
// HasItem verifies the existence of an Item in cache
-func (chSv1 *CacheSv1) HasItem(args *dispatchers.ArgsGetCacheItemWithApiKey,
+func (chSv1 *CacheSv1) HasItem(args *utils.ArgsGetCacheItemWithArgDispatcher,
reply *bool) error {
- return chSv1.cacheS.V1HasItem(&args.ArgsGetCacheItem, reply)
+ return chSv1.cacheS.V1HasItem(args, reply)
}
// GetItemExpiryTime returns the expiryTime for an item
-func (chSv1 *CacheSv1) GetItemExpiryTime(args *dispatchers.ArgsGetCacheItemWithApiKey,
+func (chSv1 *CacheSv1) GetItemExpiryTime(args *utils.ArgsGetCacheItemWithArgDispatcher,
reply *time.Time) error {
- return chSv1.cacheS.V1GetItemExpiryTime(&args.ArgsGetCacheItem, reply)
+ return chSv1.cacheS.V1GetItemExpiryTime(args, reply)
}
// RemoveItem removes the Item with ID from cache
-func (chSv1 *CacheSv1) RemoveItem(args *dispatchers.ArgsGetCacheItemWithApiKey,
+func (chSv1 *CacheSv1) RemoveItem(args *utils.ArgsGetCacheItemWithArgDispatcher,
reply *string) error {
- return chSv1.cacheS.V1RemoveItem(&args.ArgsGetCacheItem, reply)
+ return chSv1.cacheS.V1RemoveItem(args, reply)
}
// Clear will clear partitions in the cache (nil fol all, empty slice for none)
-func (chSv1 *CacheSv1) Clear(args *dispatchers.AttrCacheIDsWithApiKey,
+func (chSv1 *CacheSv1) Clear(args *utils.AttrCacheIDsWithArgDispatcher,
reply *string) error {
- return chSv1.cacheS.V1Clear(args.CacheIDs, reply)
+ return chSv1.cacheS.V1Clear(args, reply)
}
// FlushCache wipes out cache for a prefix or completely
-func (chSv1 *CacheSv1) FlushCache(args dispatchers.AttrReloadCacheWithApiKey, reply *string) (err error) {
- return chSv1.cacheS.V1FlushCache(args.AttrReloadCache, reply)
+func (chSv1 *CacheSv1) FlushCache(args utils.AttrReloadCacheWithArgDispatcher, reply *string) (err error) {
+ return chSv1.cacheS.V1FlushCache(args, reply)
}
// GetCacheStats returns CacheStats filtered by cacheIDs
-func (chSv1 *CacheSv1) GetCacheStats(args *dispatchers.AttrCacheIDsWithApiKey,
+func (chSv1 *CacheSv1) GetCacheStats(args *utils.AttrCacheIDsWithArgDispatcher,
rply *map[string]*ltcache.CacheStats) error {
- return chSv1.cacheS.V1GetCacheStats(args.CacheIDs, rply)
+ return chSv1.cacheS.V1GetCacheStats(args, rply)
}
// PrecacheStatus checks status of active precache processes
-func (chSv1 *CacheSv1) PrecacheStatus(args *dispatchers.AttrCacheIDsWithApiKey, rply *map[string]string) error {
- return chSv1.cacheS.V1PrecacheStatus(args.CacheIDs, rply)
+func (chSv1 *CacheSv1) PrecacheStatus(args *utils.AttrCacheIDsWithArgDispatcher, rply *map[string]string) error {
+ return chSv1.cacheS.V1PrecacheStatus(args, rply)
}
// HasGroup checks existence of a group in cache
-func (chSv1 *CacheSv1) HasGroup(args *dispatchers.ArgsGetGroupWithApiKey,
+func (chSv1 *CacheSv1) HasGroup(args *utils.ArgsGetGroupWithArgDispatcher,
rply *bool) (err error) {
- return chSv1.cacheS.V1HasGroup(&args.ArgsGetGroup, rply)
+ return chSv1.cacheS.V1HasGroup(args, rply)
}
// GetGroupItemIDs returns a list of itemIDs in a cache group
-func (chSv1 *CacheSv1) GetGroupItemIDs(args *dispatchers.ArgsGetGroupWithApiKey,
+func (chSv1 *CacheSv1) GetGroupItemIDs(args *utils.ArgsGetGroupWithArgDispatcher,
rply *[]string) (err error) {
- return chSv1.cacheS.V1GetGroupItemIDs(&args.ArgsGetGroup, rply)
+ return chSv1.cacheS.V1GetGroupItemIDs(args, rply)
}
// RemoveGroup will remove a group and all items belonging to it from cache
-func (chSv1 *CacheSv1) RemoveGroup(args *dispatchers.ArgsGetGroupWithApiKey,
+func (chSv1 *CacheSv1) RemoveGroup(args *utils.ArgsGetGroupWithArgDispatcher,
rply *string) (err error) {
- return chSv1.cacheS.V1RemoveGroup(&args.ArgsGetGroup, rply)
+ return chSv1.cacheS.V1RemoveGroup(args, rply)
}
// ReloadCache reloads cache from DB for a prefix or completely
-func (chSv1 *CacheSv1) ReloadCache(args dispatchers.AttrReloadCacheWithApiKey, reply *string) (err error) {
- return chSv1.cacheS.V1ReloadCache(args.AttrReloadCache, reply)
+func (chSv1 *CacheSv1) ReloadCache(args utils.AttrReloadCacheWithArgDispatcher, reply *string) (err error) {
+ return chSv1.cacheS.V1ReloadCache(args, reply)
}
// LoadCache loads cache from DB for a prefix or completely
-func (chSv1 *CacheSv1) LoadCache(args dispatchers.AttrReloadCacheWithApiKey, reply *string) (err error) {
- return chSv1.cacheS.V1LoadCache(args.AttrReloadCache, reply)
+func (chSv1 *CacheSv1) LoadCache(args utils.AttrReloadCacheWithArgDispatcher, reply *string) (err error) {
+ return chSv1.cacheS.V1LoadCache(args, reply)
}
// Ping used to detreminate if component is active
diff --git a/apier/v1/caches_it_test.go b/apier/v1/caches_it_test.go
index d29399a0c..e3acd42b0 100644
--- a/apier/v1/caches_it_test.go
+++ b/apier/v1/caches_it_test.go
@@ -221,7 +221,7 @@ func testCacheSReload(t *testing.T) {
func testCacheSGetItemIDs(t *testing.T) {
var rcvKeys []string
var expKeys []string
- argsAPI := engine.ArgsGetCacheItemIDs{
+ argsAPI := utils.ArgsGetCacheItemIDs{
CacheID: utils.CacheThresholdProfiles,
ItemIDPrefix: "NotExistent",
}
@@ -230,7 +230,7 @@ func testCacheSGetItemIDs(t *testing.T) {
}
expKeys = []string{"cgrates.org:Threshold1"}
- argsAPI = engine.ArgsGetCacheItemIDs{
+ argsAPI = utils.ArgsGetCacheItemIDs{
CacheID: utils.CacheThresholdProfiles,
}
if err := chcRPC.Call(utils.CacheSv1GetItemIDs, argsAPI, &rcvKeys); err != nil {
@@ -244,7 +244,7 @@ func testCacheSGetItemIDs(t *testing.T) {
func testCacheSHasItem(t *testing.T) {
var reply bool
var expected bool
- argsAPI := engine.ArgsGetCacheItem{
+ argsAPI := utils.ArgsGetCacheItem{
CacheID: utils.CacheThresholdProfiles,
ItemID: "NotExistent",
}
@@ -255,7 +255,7 @@ func testCacheSHasItem(t *testing.T) {
}
expected = true
- argsAPI = engine.ArgsGetCacheItem{
+ argsAPI = utils.ArgsGetCacheItem{
CacheID: utils.CacheThresholdProfiles,
ItemID: "cgrates.org:Threshold1",
}
@@ -269,7 +269,7 @@ func testCacheSHasItem(t *testing.T) {
func testCacheSGetItemExpiryTime(t *testing.T) {
var reply time.Time
var expected time.Time
- argsAPI := engine.ArgsGetCacheItem{
+ argsAPI := utils.ArgsGetCacheItem{
CacheID: utils.CacheThresholdProfiles,
ItemID: "NotExistent",
}
@@ -278,7 +278,7 @@ func testCacheSGetItemExpiryTime(t *testing.T) {
}
// expected = true
- argsAPI = engine.ArgsGetCacheItem{
+ argsAPI = utils.ArgsGetCacheItem{
CacheID: utils.CacheThresholdProfiles,
ItemID: "cgrates.org:Threshold1",
}
@@ -301,7 +301,7 @@ func testCacheSReloadCache(t *testing.T) {
func testCacheSRemoveItem(t *testing.T) {
var reply bool
- argsAPI := engine.ArgsGetCacheItem{
+ argsAPI := utils.ArgsGetCacheItem{
CacheID: utils.CacheThresholdProfiles,
ItemID: "cgrates.org:Threshold1",
}
diff --git a/apier/v1/chargers.go b/apier/v1/chargers.go
index d349d95eb..c92b5f147 100644
--- a/apier/v1/chargers.go
+++ b/apier/v1/chargers.go
@@ -77,7 +77,7 @@ func (apierV1 *ApierV1) SetChargerProfile(arg *ChargerWithCache, reply *string)
return utils.APIErrorHandler(err)
}
//handle caching for ChargerProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheChargerProfiles,
ItemID: arg.TenantID(),
}
@@ -102,7 +102,7 @@ func (apierV1 *ApierV1) RemoveChargerProfile(arg utils.TenantIDWithCache, reply
return utils.APIErrorHandler(err)
}
//handle caching for ChargerProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheChargerProfiles,
ItemID: arg.TenantID(),
}
diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go
index de596a8aa..f0e706041 100755
--- a/apier/v1/dispatcher.go
+++ b/apier/v1/dispatcher.go
@@ -82,7 +82,7 @@ func (apierV1 *ApierV1) SetDispatcherProfile(args *DispatcherWithCache, reply *s
return utils.APIErrorHandler(err)
}
//handle caching for DispatcherProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheDispatcherProfiles,
ItemID: args.TenantID(),
}
@@ -107,7 +107,7 @@ func (apierV1 *ApierV1) RemoveDispatcherProfile(arg *utils.TenantIDWithCache, re
return utils.APIErrorHandler(err)
}
//handle caching for DispatcherProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheDispatcherProfiles,
ItemID: arg.TenantID(),
}
@@ -171,7 +171,7 @@ func (apierV1 *ApierV1) SetDispatcherHost(args *DispatcherHostWithCache, reply *
return utils.APIErrorHandler(err)
}
//handle caching for DispatcherProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheDispatcherHosts,
ItemID: args.TenantID(),
}
@@ -196,7 +196,7 @@ func (apierV1 *ApierV1) RemoveDispatcherHost(arg *utils.TenantIDWithCache, reply
return utils.APIErrorHandler(err)
}
//handle caching for DispatcherProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheDispatcherHosts,
ItemID: arg.TenantID(),
}
@@ -552,76 +552,76 @@ type DispatcherCacheSv1 struct {
}
// GetItemIDs returns the IDs for cacheID with given prefix
-func (dS *DispatcherCacheSv1) GetItemIDs(args *dispatchers.ArgsGetCacheItemIDsWithApiKey,
+func (dS *DispatcherCacheSv1) GetItemIDs(args *utils.ArgsGetCacheItemIDsWithArgDispatcher,
reply *[]string) error {
return dS.dS.CacheSv1GetItemIDs(args, reply)
}
// HasItem verifies the existence of an Item in cache
-func (dS *DispatcherCacheSv1) HasItem(args *dispatchers.ArgsGetCacheItemWithApiKey,
+func (dS *DispatcherCacheSv1) HasItem(args *utils.ArgsGetCacheItemWithArgDispatcher,
reply *bool) error {
return dS.dS.CacheSv1HasItem(args, reply)
}
// GetItemExpiryTime returns the expiryTime for an item
-func (dS *DispatcherCacheSv1) GetItemExpiryTime(args *dispatchers.ArgsGetCacheItemWithApiKey,
+func (dS *DispatcherCacheSv1) GetItemExpiryTime(args *utils.ArgsGetCacheItemWithArgDispatcher,
reply *time.Time) error {
return dS.dS.CacheSv1GetItemExpiryTime(args, reply)
}
// RemoveItem removes the Item with ID from cache
-func (dS *DispatcherCacheSv1) RemoveItem(args *dispatchers.ArgsGetCacheItemWithApiKey,
+func (dS *DispatcherCacheSv1) RemoveItem(args *utils.ArgsGetCacheItemWithArgDispatcher,
reply *string) error {
return dS.dS.CacheSv1RemoveItem(args, reply)
}
// Clear will clear partitions in the cache (nil fol all, empty slice for none)
-func (dS *DispatcherCacheSv1) Clear(args *dispatchers.AttrCacheIDsWithApiKey,
+func (dS *DispatcherCacheSv1) Clear(args *utils.AttrCacheIDsWithArgDispatcher,
reply *string) error {
return dS.dS.CacheSv1Clear(args, reply)
}
// FlushCache wipes out cache for a prefix or completely
-func (dS *DispatcherCacheSv1) FlushCache(args dispatchers.AttrReloadCacheWithApiKey, reply *string) (err error) {
+func (dS *DispatcherCacheSv1) FlushCache(args utils.AttrReloadCacheWithArgDispatcher, reply *string) (err error) {
return dS.dS.CacheSv1FlushCache(args, reply)
}
// GetCacheStats returns CacheStats filtered by cacheIDs
-func (dS *DispatcherCacheSv1) GetCacheStats(args *dispatchers.AttrCacheIDsWithApiKey,
+func (dS *DispatcherCacheSv1) GetCacheStats(args *utils.AttrCacheIDsWithArgDispatcher,
reply *map[string]*ltcache.CacheStats) error {
return dS.dS.CacheSv1GetCacheStats(args, reply)
}
// PrecacheStatus checks status of active precache processes
-func (dS *DispatcherCacheSv1) PrecacheStatus(args *dispatchers.AttrCacheIDsWithApiKey, reply *map[string]string) error {
+func (dS *DispatcherCacheSv1) PrecacheStatus(args *utils.AttrCacheIDsWithArgDispatcher, reply *map[string]string) error {
return dS.dS.CacheSv1PrecacheStatus(args, reply)
}
// HasGroup checks existence of a group in cache
-func (dS *DispatcherCacheSv1) HasGroup(args *dispatchers.ArgsGetGroupWithApiKey,
+func (dS *DispatcherCacheSv1) HasGroup(args *utils.ArgsGetGroupWithArgDispatcher,
reply *bool) (err error) {
return dS.dS.CacheSv1HasGroup(args, reply)
}
// GetGroupItemIDs returns a list of itemIDs in a cache group
-func (dS *DispatcherCacheSv1) GetGroupItemIDs(args *dispatchers.ArgsGetGroupWithApiKey,
+func (dS *DispatcherCacheSv1) GetGroupItemIDs(args *utils.ArgsGetGroupWithArgDispatcher,
reply *[]string) (err error) {
return dS.dS.CacheSv1GetGroupItemIDs(args, reply)
}
// RemoveGroup will remove a group and all items belonging to it from cache
-func (dS *DispatcherCacheSv1) RemoveGroup(args *dispatchers.ArgsGetGroupWithApiKey,
+func (dS *DispatcherCacheSv1) RemoveGroup(args *utils.ArgsGetGroupWithArgDispatcher,
reply *string) (err error) {
return dS.dS.CacheSv1RemoveGroup(args, reply)
}
// ReloadCache reloads cache from DB for a prefix or completely
-func (dS *DispatcherCacheSv1) ReloadCache(args dispatchers.AttrReloadCacheWithApiKey, reply *string) (err error) {
+func (dS *DispatcherCacheSv1) ReloadCache(args utils.AttrReloadCacheWithArgDispatcher, reply *string) (err error) {
return dS.dS.CacheSv1ReloadCache(args, reply)
}
// LoadCache loads cache from DB for a prefix or completely
-func (dS *DispatcherCacheSv1) LoadCache(args dispatchers.AttrReloadCacheWithApiKey, reply *string) (err error) {
+func (dS *DispatcherCacheSv1) LoadCache(args utils.AttrReloadCacheWithArgDispatcher, reply *string) (err error) {
return dS.dS.CacheSv1LoadCache(args, reply)
}
diff --git a/apier/v1/dispatcher_interface.go b/apier/v1/dispatcher_interface.go
index 506457519..e32ff59c6 100644
--- a/apier/v1/dispatcher_interface.go
+++ b/apier/v1/dispatcher_interface.go
@@ -104,19 +104,19 @@ type ResponderInterface interface {
}
type CacheSv1Interface interface {
- GetItemIDs(args *dispatchers.ArgsGetCacheItemIDsWithApiKey, reply *[]string) error
- HasItem(args *dispatchers.ArgsGetCacheItemWithApiKey, reply *bool) error
- GetItemExpiryTime(args *dispatchers.ArgsGetCacheItemWithApiKey, reply *time.Time) error
- RemoveItem(args *dispatchers.ArgsGetCacheItemWithApiKey, reply *string) error
- Clear(cacheIDs *dispatchers.AttrCacheIDsWithApiKey, reply *string) error
- FlushCache(args dispatchers.AttrReloadCacheWithApiKey, reply *string) error
- GetCacheStats(cacheIDs *dispatchers.AttrCacheIDsWithApiKey, rply *map[string]*ltcache.CacheStats) error
- PrecacheStatus(cacheIDs *dispatchers.AttrCacheIDsWithApiKey, rply *map[string]string) error
- HasGroup(args *dispatchers.ArgsGetGroupWithApiKey, rply *bool) error
- GetGroupItemIDs(args *dispatchers.ArgsGetGroupWithApiKey, rply *[]string) error
- RemoveGroup(args *dispatchers.ArgsGetGroupWithApiKey, rply *string) error
- ReloadCache(attrs dispatchers.AttrReloadCacheWithApiKey, reply *string) error
- LoadCache(args dispatchers.AttrReloadCacheWithApiKey, reply *string) error
+ GetItemIDs(args *utils.ArgsGetCacheItemIDsWithArgDispatcher, reply *[]string) error
+ HasItem(args *utils.ArgsGetCacheItemWithArgDispatcher, reply *bool) error
+ GetItemExpiryTime(args *utils.ArgsGetCacheItemWithArgDispatcher, reply *time.Time) error
+ RemoveItem(args *utils.ArgsGetCacheItemWithArgDispatcher, reply *string) error
+ Clear(cacheIDs *utils.AttrCacheIDsWithArgDispatcher, reply *string) error
+ FlushCache(args utils.AttrReloadCacheWithArgDispatcher, reply *string) error
+ GetCacheStats(cacheIDs *utils.AttrCacheIDsWithArgDispatcher, rply *map[string]*ltcache.CacheStats) error
+ PrecacheStatus(cacheIDs *utils.AttrCacheIDsWithArgDispatcher, rply *map[string]string) error
+ HasGroup(args *utils.ArgsGetGroupWithArgDispatcher, rply *bool) error
+ GetGroupItemIDs(args *utils.ArgsGetGroupWithArgDispatcher, rply *[]string) error
+ RemoveGroup(args *utils.ArgsGetGroupWithArgDispatcher, rply *string) error
+ ReloadCache(attrs utils.AttrReloadCacheWithArgDispatcher, reply *string) error
+ LoadCache(args utils.AttrReloadCacheWithArgDispatcher, reply *string) error
Ping(ign *utils.CGREventWithArgDispatcher, reply *string) error
}
diff --git a/apier/v1/filters.go b/apier/v1/filters.go
index c51a94402..fbdcb2f91 100644
--- a/apier/v1/filters.go
+++ b/apier/v1/filters.go
@@ -43,7 +43,7 @@ func (apierV1 *ApierV1) SetFilter(arg *FilterWithCache, reply *string) error {
return utils.APIErrorHandler(err)
}
//handle caching for Filter
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheFilters,
ItemID: arg.TenantID(),
}
@@ -101,7 +101,7 @@ func (apierV1 *ApierV1) RemoveFilter(arg utils.TenantIDWithCache, reply *string)
return utils.APIErrorHandler(err)
}
//handle caching for Filter
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheFilters,
ItemID: arg.TenantID(),
}
diff --git a/apier/v1/libapier.go b/apier/v1/libapier.go
index dcee380d3..86a2beefd 100644
--- a/apier/v1/libapier.go
+++ b/apier/v1/libapier.go
@@ -20,7 +20,6 @@ package v1
import (
"github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -37,7 +36,7 @@ func GetCacheOpt(apiOpt *string) string {
// composeArgsReload add the ItemID to AttrReloadCache
// for a specific CacheID
-func composeArgsReload(args engine.ArgsGetCacheItem) (rpl utils.AttrReloadCache) {
+func composeArgsReload(args utils.ArgsGetCacheItem) (rpl utils.AttrReloadCache) {
rpl = utils.InitAttrReloadCache()
switch args.CacheID {
case utils.CacheResourceProfiles:
diff --git a/apier/v1/precache_it_test.go b/apier/v1/precache_it_test.go
index 702db5fdf..896645eff 100644
--- a/apier/v1/precache_it_test.go
+++ b/apier/v1/precache_it_test.go
@@ -29,7 +29,6 @@ import (
"time"
"github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/dispatchers"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
"github.com/cgrates/ltcache"
@@ -102,7 +101,7 @@ func testPrecacheRpcConn(t *testing.T) {
}
func testPrecacheGetItemIDs(t *testing.T) {
- args := &engine.ArgsGetCacheItemIDs{
+ args := &utils.ArgsGetCacheItemIDs{
CacheID: utils.MetaDefault,
}
var reply *[]string
@@ -114,7 +113,7 @@ func testPrecacheGetItemIDs(t *testing.T) {
func testPrecacheGetCacheStatsBeforeLoad(t *testing.T) {
var reply *map[string]*ltcache.CacheStats
- args := &dispatchers.AttrCacheIDsWithApiKey{
+ args := &utils.AttrCacheIDsWithArgDispatcher{
CacheIDs: []string{},
}
dfltStats := engine.GetDefaultEmptyCacheStats()
@@ -148,7 +147,7 @@ func testPrecacheRestartEngine(t *testing.T) {
func testPrecacheGetCacheStatsAfterRestart(t *testing.T) {
var reply *map[string]*ltcache.CacheStats
- args := &dispatchers.AttrCacheIDsWithApiKey{
+ args := &utils.AttrCacheIDsWithArgDispatcher{
CacheIDs: []string{},
}
expectedStats := &map[string]*ltcache.CacheStats{
diff --git a/apier/v1/resourcesv1.go b/apier/v1/resourcesv1.go
index 7567a4808..81843e9a1 100644
--- a/apier/v1/resourcesv1.go
+++ b/apier/v1/resourcesv1.go
@@ -120,7 +120,7 @@ func (apierV1 *ApierV1) SetResourceProfile(arg *ResourceWithCache, reply *string
return utils.APIErrorHandler(err)
}
//handle caching for ResourceProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheResourceProfiles,
ItemID: arg.TenantID(),
}
@@ -138,7 +138,7 @@ func (apierV1 *ApierV1) SetResourceProfile(arg *ResourceWithCache, reply *string
return utils.APIErrorHandler(err)
}
//handle caching for Resource
- argCache = engine.ArgsGetCacheItem{
+ argCache = utils.ArgsGetCacheItem{
CacheID: utils.CacheResources,
ItemID: arg.TenantID(),
}
@@ -160,7 +160,7 @@ func (apierV1 *ApierV1) RemoveResourceProfile(arg utils.TenantIDWithCache, reply
return utils.APIErrorHandler(err)
}
//handle caching for ResourceProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheResourceProfiles,
ItemID: arg.TenantID(),
}
@@ -177,7 +177,7 @@ func (apierV1 *ApierV1) RemoveResourceProfile(arg utils.TenantIDWithCache, reply
return utils.APIErrorHandler(err)
}
//handle caching for Resource
- argCache = engine.ArgsGetCacheItem{
+ argCache = utils.ArgsGetCacheItem{
CacheID: utils.CacheResources,
ItemID: arg.TenantID(),
}
diff --git a/apier/v1/stats.go b/apier/v1/stats.go
index dfa2f6224..430cf3327 100644
--- a/apier/v1/stats.go
+++ b/apier/v1/stats.go
@@ -80,7 +80,7 @@ func (apierV1 *ApierV1) SetStatQueueProfile(arg *StatQueueWithCache, reply *stri
return utils.APIErrorHandler(err)
}
//handle caching for StatQueueProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheStatQueueProfiles,
ItemID: arg.TenantID(),
}
@@ -103,7 +103,7 @@ func (apierV1 *ApierV1) SetStatQueueProfile(arg *StatQueueWithCache, reply *stri
return utils.APIErrorHandler(err)
}
//handle caching for StatQueues
- argCache = engine.ArgsGetCacheItem{
+ argCache = utils.ArgsGetCacheItem{
CacheID: utils.CacheStatQueues,
ItemID: arg.TenantID(),
}
@@ -125,7 +125,7 @@ func (apierV1 *ApierV1) RemoveStatQueueProfile(args *utils.TenantIDWithCache, re
return utils.APIErrorHandler(err)
}
//handle caching for StatQueueProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheStatQueueProfiles,
ItemID: args.TenantID(),
}
@@ -142,7 +142,7 @@ func (apierV1 *ApierV1) RemoveStatQueueProfile(args *utils.TenantIDWithCache, re
return utils.APIErrorHandler(err)
}
//handle caching for StatQueues
- argCache = engine.ArgsGetCacheItem{
+ argCache = utils.ArgsGetCacheItem{
CacheID: utils.CacheStatQueues,
ItemID: args.TenantID(),
}
diff --git a/apier/v1/suppliers.go b/apier/v1/suppliers.go
index 533bdbf8c..9102e7127 100644
--- a/apier/v1/suppliers.go
+++ b/apier/v1/suppliers.go
@@ -77,7 +77,7 @@ func (apierV1 *ApierV1) SetSupplierProfile(args *SupplierWithCache, reply *strin
return utils.APIErrorHandler(err)
}
//handle caching for SupplierProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheSupplierProfiles,
ItemID: args.TenantID(),
}
@@ -101,7 +101,7 @@ func (apierV1 *ApierV1) RemoveSupplierProfile(args *utils.TenantIDWithCache, rep
return utils.APIErrorHandler(err)
}
//handle caching for SupplierProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheSupplierProfiles,
ItemID: args.TenantID(),
}
diff --git a/apier/v1/thresholds.go b/apier/v1/thresholds.go
index 4c94167df..592e37b20 100644
--- a/apier/v1/thresholds.go
+++ b/apier/v1/thresholds.go
@@ -114,7 +114,7 @@ func (apierV1 *ApierV1) SetThresholdProfile(args *ThresholdWithCache, reply *str
return utils.APIErrorHandler(err)
}
//handle caching for ThresholdProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheThresholdProfiles,
ItemID: args.TenantID(),
}
@@ -129,7 +129,7 @@ func (apierV1 *ApierV1) SetThresholdProfile(args *ThresholdWithCache, reply *str
return err
}
//handle caching for Threshold
- argCache = engine.ArgsGetCacheItem{
+ argCache = utils.ArgsGetCacheItem{
CacheID: utils.CacheThresholds,
ItemID: args.TenantID(),
}
@@ -151,7 +151,7 @@ func (apierV1 *ApierV1) RemoveThresholdProfile(args *utils.TenantIDWithCache, re
return utils.APIErrorHandler(err)
}
//handle caching for ThresholdProfile
- argCache := engine.ArgsGetCacheItem{
+ argCache := utils.ArgsGetCacheItem{
CacheID: utils.CacheThresholdProfiles,
ItemID: args.TenantID(),
}
@@ -168,7 +168,7 @@ func (apierV1 *ApierV1) RemoveThresholdProfile(args *utils.TenantIDWithCache, re
return utils.APIErrorHandler(err)
}
//handle caching for Threshold
- argCache = engine.ArgsGetCacheItem{
+ argCache = utils.ArgsGetCacheItem{
CacheID: utils.CacheThresholds,
ItemID: args.TenantID(),
}
diff --git a/apier/v2/apier.go b/apier/v2/apier.go
index 6b86a5240..d4f4735f6 100644
--- a/apier/v2/apier.go
+++ b/apier/v2/apier.go
@@ -149,7 +149,7 @@ func (self *ApierV2) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
}
utils.Logger.Info("ApierV2.LoadTariffPlanFromFolder, reloading cache.")
- if err := loader.ReloadCache(attrs.FlushDb, true); err != nil {
+ if err := loader.ReloadCache(attrs.FlushDb, true, attrs.ArgDispatcher); err != nil {
return utils.NewErrServerError(err)
}
loadHistList, err := self.DataManager.DataDB().GetLoadHistory(1, true, utils.NonTransactional)
diff --git a/apier/v2/attributes.go b/apier/v2/attributes.go
index 795f65634..50feb0249 100644
--- a/apier/v2/attributes.go
+++ b/apier/v2/attributes.go
@@ -48,7 +48,7 @@ func (apierV2 *ApierV2) SetAttributeProfile(arg *AttributeWithCache, reply *stri
map[string]int64{utils.CacheAttributeProfiles: time.Now().UnixNano()}); err != nil {
return utils.APIErrorHandler(err)
}
- args := engine.ArgsGetCacheItem{
+ args := utils.ArgsGetCacheItem{
CacheID: utils.CacheAttributeProfiles,
ItemID: alsPrf.TenantID(),
}
diff --git a/cmd/cgr-loader/cgr-loader.go b/cmd/cgr-loader/cgr-loader.go
index 5ee9596f8..10c61b1d9 100755
--- a/cmd/cgr-loader/cgr-loader.go
+++ b/cmd/cgr-loader/cgr-loader.go
@@ -96,6 +96,8 @@ var (
disableReverse = cgrLoaderFlags.Bool("disable_reverse_mappings", false, "Will disable reverse mappings rebuilding")
flushStorDB = cgrLoaderFlags.Bool("flush_stordb", false, "Remove tariff plan data for id from the database")
remove = cgrLoaderFlags.Bool("remove", false, "Will remove instead of adding data from DB")
+ apiKey = cgrLoaderFlags.String("api_key", "", "Api Key used to comosed ArgDispatcher")
+ routeID = cgrLoaderFlags.String("route_id", "", "RouteID used to comosed ArgDispatcher")
err error
dm *engine.DataManager
@@ -351,7 +353,10 @@ func main() {
log.Fatal("Could not write to database: ", err)
}
// reload cache
- if err := tpReader.ReloadCache(*flush, *verbose); err != nil {
+ if err := tpReader.ReloadCache(*flush, *verbose, &utils.ArgDispatcher{
+ APIKey: apiKey,
+ RouteID: routeID,
+ }); err != nil {
log.Fatal("Could not reload cache: ", err)
}
} else {
diff --git a/console/cache_group_item_id.go b/console/cache_group_item_id.go
index c02457d76..b75e09300 100644
--- a/console/cache_group_item_id.go
+++ b/console/cache_group_item_id.go
@@ -19,7 +19,6 @@ along with this program. If not, see
package console
import (
- "github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -27,7 +26,7 @@ func init() {
c := &CmdCacheGetGroupItemIDs{
name: "cache_group_item_ids",
rpcMethod: utils.CacheSv1GetGroupItemIDs,
- rpcParams: &engine.ArgsGetGroup{},
+ rpcParams: &utils.ArgsGetGroup{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -37,7 +36,7 @@ func init() {
type CmdCacheGetGroupItemIDs struct {
name string
rpcMethod string
- rpcParams *engine.ArgsGetGroup
+ rpcParams *utils.ArgsGetGroup
*CommandExecuter
}
@@ -51,7 +50,7 @@ func (self *CmdCacheGetGroupItemIDs) RpcMethod() string {
func (self *CmdCacheGetGroupItemIDs) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
- self.rpcParams = &engine.ArgsGetGroup{}
+ self.rpcParams = &utils.ArgsGetGroup{}
}
return self.rpcParams
}
diff --git a/console/cache_has_group.go b/console/cache_has_group.go
index 79ba811d8..bd2b6aacc 100644
--- a/console/cache_has_group.go
+++ b/console/cache_has_group.go
@@ -19,7 +19,6 @@ along with this program. If not, see
package console
import (
- "github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -27,7 +26,7 @@ func init() {
c := &CmdCacheHasGroup{
name: "cache_has_group",
rpcMethod: utils.CacheSv1HasGroup,
- rpcParams: &engine.ArgsGetGroup{},
+ rpcParams: &utils.ArgsGetGroup{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -37,7 +36,7 @@ func init() {
type CmdCacheHasGroup struct {
name string
rpcMethod string
- rpcParams *engine.ArgsGetGroup
+ rpcParams *utils.ArgsGetGroup
*CommandExecuter
}
@@ -51,7 +50,7 @@ func (self *CmdCacheHasGroup) RpcMethod() string {
func (self *CmdCacheHasGroup) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
- self.rpcParams = &engine.ArgsGetGroup{}
+ self.rpcParams = &utils.ArgsGetGroup{}
}
return self.rpcParams
}
diff --git a/console/cache_has_item.go b/console/cache_has_item.go
index eacb4b7db..24cb903e5 100644
--- a/console/cache_has_item.go
+++ b/console/cache_has_item.go
@@ -19,7 +19,6 @@ along with this program. If not, see
package console
import (
- "github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -27,7 +26,7 @@ func init() {
c := &CmdCacheHasItem{
name: "cache_has_item",
rpcMethod: utils.CacheSv1HasItem,
- rpcParams: &engine.ArgsGetCacheItem{},
+ rpcParams: &utils.ArgsGetCacheItem{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -37,7 +36,7 @@ func init() {
type CmdCacheHasItem struct {
name string
rpcMethod string
- rpcParams *engine.ArgsGetCacheItem
+ rpcParams *utils.ArgsGetCacheItem
*CommandExecuter
}
@@ -51,7 +50,7 @@ func (self *CmdCacheHasItem) RpcMethod() string {
func (self *CmdCacheHasItem) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
- self.rpcParams = &engine.ArgsGetCacheItem{}
+ self.rpcParams = &utils.ArgsGetCacheItem{}
}
return self.rpcParams
}
diff --git a/console/cache_item_expiry_time.go b/console/cache_item_expiry_time.go
index f02b31bcf..99b40bc77 100644
--- a/console/cache_item_expiry_time.go
+++ b/console/cache_item_expiry_time.go
@@ -19,7 +19,6 @@ along with this program. If not, see
package console
import (
- "github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -27,7 +26,7 @@ func init() {
c := &CmdCacheGetItemExpiryTime{
name: "cache_item_expiry_time",
rpcMethod: utils.CacheSv1GetItemExpiryTime,
- rpcParams: &engine.ArgsGetCacheItem{},
+ rpcParams: &utils.ArgsGetCacheItem{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -37,7 +36,7 @@ func init() {
type CmdCacheGetItemExpiryTime struct {
name string
rpcMethod string
- rpcParams *engine.ArgsGetCacheItem
+ rpcParams *utils.ArgsGetCacheItem
*CommandExecuter
}
@@ -51,7 +50,7 @@ func (self *CmdCacheGetItemExpiryTime) RpcMethod() string {
func (self *CmdCacheGetItemExpiryTime) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
- self.rpcParams = &engine.ArgsGetCacheItem{}
+ self.rpcParams = &utils.ArgsGetCacheItem{}
}
return self.rpcParams
}
diff --git a/console/cache_item_ids.go b/console/cache_item_ids.go
index 78ba4602f..3f1ac0d75 100644
--- a/console/cache_item_ids.go
+++ b/console/cache_item_ids.go
@@ -19,7 +19,6 @@ along with this program. If not, see
package console
import (
- "github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -27,7 +26,7 @@ func init() {
c := &CmdCacheGetItemIDs{
name: "cache_item_ids",
rpcMethod: utils.CacheSv1GetItemIDs,
- rpcParams: &engine.ArgsGetCacheItemIDs{},
+ rpcParams: &utils.ArgsGetCacheItemIDs{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -37,7 +36,7 @@ func init() {
type CmdCacheGetItemIDs struct {
name string
rpcMethod string
- rpcParams *engine.ArgsGetCacheItemIDs
+ rpcParams *utils.ArgsGetCacheItemIDs
*CommandExecuter
}
@@ -51,7 +50,7 @@ func (self *CmdCacheGetItemIDs) RpcMethod() string {
func (self *CmdCacheGetItemIDs) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
- self.rpcParams = &engine.ArgsGetCacheItemIDs{}
+ self.rpcParams = &utils.ArgsGetCacheItemIDs{}
}
return self.rpcParams
}
diff --git a/console/cache_reload.go b/console/cache_reload.go
index ed9fcf471..047d8d377 100644
--- a/console/cache_reload.go
+++ b/console/cache_reload.go
@@ -33,7 +33,7 @@ func init() {
type CmdReloadCache struct {
name string
rpcMethod string
- rpcParams *utils.AttrReloadCache
+ rpcParams *utils.AttrReloadCacheWithArgDispatcher
rpcResult string
*CommandExecuter
}
@@ -48,7 +48,7 @@ func (self *CmdReloadCache) RpcMethod() string {
func (self *CmdReloadCache) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
- self.rpcParams = &utils.AttrReloadCache{}
+ self.rpcParams = &utils.AttrReloadCacheWithArgDispatcher{}
}
return self.rpcParams
}
diff --git a/console/cache_remove_group.go b/console/cache_remove_group.go
index 1dd054962..ecb17617c 100644
--- a/console/cache_remove_group.go
+++ b/console/cache_remove_group.go
@@ -19,7 +19,6 @@ along with this program. If not, see
package console
import (
- "github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -27,7 +26,7 @@ func init() {
c := &CmdCacheRemoveGroup{
name: "cache_remove_group",
rpcMethod: utils.CacheSv1RemoveGroup,
- rpcParams: &engine.ArgsGetGroup{},
+ rpcParams: &utils.ArgsGetGroup{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -37,7 +36,7 @@ func init() {
type CmdCacheRemoveGroup struct {
name string
rpcMethod string
- rpcParams *engine.ArgsGetGroup
+ rpcParams *utils.ArgsGetGroup
*CommandExecuter
}
@@ -51,7 +50,7 @@ func (self *CmdCacheRemoveGroup) RpcMethod() string {
func (self *CmdCacheRemoveGroup) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
- self.rpcParams = &engine.ArgsGetGroup{}
+ self.rpcParams = &utils.ArgsGetGroup{}
}
return self.rpcParams
}
diff --git a/console/cache_remove_item.go b/console/cache_remove_item.go
index 731600d06..bfc70ae7d 100644
--- a/console/cache_remove_item.go
+++ b/console/cache_remove_item.go
@@ -19,7 +19,6 @@ along with this program. If not, see
package console
import (
- "github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -27,7 +26,7 @@ func init() {
c := &CmdCacheRemoveItem{
name: "cache_remove_item",
rpcMethod: utils.CacheSv1RemoveItem,
- rpcParams: &engine.ArgsGetCacheItem{},
+ rpcParams: &utils.ArgsGetCacheItem{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -37,7 +36,7 @@ func init() {
type CmdCacheRemoveItem struct {
name string
rpcMethod string
- rpcParams *engine.ArgsGetCacheItem
+ rpcParams *utils.ArgsGetCacheItem
*CommandExecuter
}
@@ -51,7 +50,7 @@ func (self *CmdCacheRemoveItem) RpcMethod() string {
func (self *CmdCacheRemoveItem) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
- self.rpcParams = &engine.ArgsGetCacheItem{}
+ self.rpcParams = &utils.ArgsGetCacheItem{}
}
return self.rpcParams
}
diff --git a/dispatchers/caches.go b/dispatchers/caches.go
index 1525b7e6a..f65600b44 100644
--- a/dispatchers/caches.go
+++ b/dispatchers/caches.go
@@ -43,7 +43,7 @@ func (dS *DispatcherService) CacheSv1Ping(args *utils.CGREventWithArgDispatcher,
}
// GetItemIDs returns the IDs for cacheID with given prefix
-func (dS *DispatcherService) CacheSv1GetItemIDs(args *ArgsGetCacheItemIDsWithApiKey,
+func (dS *DispatcherService) CacheSv1GetItemIDs(args *utils.ArgsGetCacheItemIDsWithArgDispatcher,
reply *[]string) (err error) {
if dS.attrS != nil {
if err = dS.authorize(utils.CacheSv1GetItemIDs,
@@ -57,7 +57,7 @@ func (dS *DispatcherService) CacheSv1GetItemIDs(args *ArgsGetCacheItemIDsWithApi
}
// HasItem verifies the existence of an Item in cache
-func (dS *DispatcherService) CacheSv1HasItem(args *ArgsGetCacheItemWithApiKey,
+func (dS *DispatcherService) CacheSv1HasItem(args *utils.ArgsGetCacheItemWithArgDispatcher,
reply *bool) (err error) {
if args.ArgDispatcher == nil {
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
@@ -74,7 +74,7 @@ func (dS *DispatcherService) CacheSv1HasItem(args *ArgsGetCacheItemWithApiKey,
}
// GetItemExpiryTime returns the expiryTime for an item
-func (dS *DispatcherService) CacheSv1GetItemExpiryTime(args *ArgsGetCacheItemWithApiKey,
+func (dS *DispatcherService) CacheSv1GetItemExpiryTime(args *utils.ArgsGetCacheItemWithArgDispatcher,
reply *time.Time) (err error) {
if args.ArgDispatcher == nil {
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
@@ -91,7 +91,7 @@ func (dS *DispatcherService) CacheSv1GetItemExpiryTime(args *ArgsGetCacheItemWit
}
// RemoveItem removes the Item with ID from cache
-func (dS *DispatcherService) CacheSv1RemoveItem(args *ArgsGetCacheItemWithApiKey,
+func (dS *DispatcherService) CacheSv1RemoveItem(args *utils.ArgsGetCacheItemWithArgDispatcher,
reply *string) (err error) {
if args.ArgDispatcher == nil {
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
@@ -108,7 +108,7 @@ func (dS *DispatcherService) CacheSv1RemoveItem(args *ArgsGetCacheItemWithApiKey
}
// Clear will clear partitions in the cache (nil fol all, empty slice for none)
-func (dS *DispatcherService) CacheSv1Clear(args *AttrCacheIDsWithApiKey,
+func (dS *DispatcherService) CacheSv1Clear(args *utils.AttrCacheIDsWithArgDispatcher,
reply *string) (err error) {
if args.ArgDispatcher == nil {
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
@@ -125,7 +125,7 @@ func (dS *DispatcherService) CacheSv1Clear(args *AttrCacheIDsWithApiKey,
}
// FlushCache wipes out cache for a prefix or completely
-func (dS *DispatcherService) CacheSv1FlushCache(args AttrReloadCacheWithApiKey, reply *string) (err error) {
+func (dS *DispatcherService) CacheSv1FlushCache(args utils.AttrReloadCacheWithArgDispatcher, reply *string) (err error) {
if args.ArgDispatcher == nil {
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
}
@@ -141,7 +141,7 @@ func (dS *DispatcherService) CacheSv1FlushCache(args AttrReloadCacheWithApiKey,
}
// GetCacheStats returns CacheStats filtered by cacheIDs
-func (dS *DispatcherService) CacheSv1GetCacheStats(args *AttrCacheIDsWithApiKey,
+func (dS *DispatcherService) CacheSv1GetCacheStats(args *utils.AttrCacheIDsWithArgDispatcher,
reply *map[string]*ltcache.CacheStats) (err error) {
if args.ArgDispatcher == nil {
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
@@ -158,7 +158,7 @@ func (dS *DispatcherService) CacheSv1GetCacheStats(args *AttrCacheIDsWithApiKey,
}
// PrecacheStatus checks status of active precache processes
-func (dS *DispatcherService) CacheSv1PrecacheStatus(args *AttrCacheIDsWithApiKey, reply *map[string]string) (err error) {
+func (dS *DispatcherService) CacheSv1PrecacheStatus(args *utils.AttrCacheIDsWithArgDispatcher, reply *map[string]string) (err error) {
if args.ArgDispatcher == nil {
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
}
@@ -174,7 +174,7 @@ func (dS *DispatcherService) CacheSv1PrecacheStatus(args *AttrCacheIDsWithApiKey
}
// HasGroup checks existence of a group in cache
-func (dS *DispatcherService) CacheSv1HasGroup(args *ArgsGetGroupWithApiKey,
+func (dS *DispatcherService) CacheSv1HasGroup(args *utils.ArgsGetGroupWithArgDispatcher,
reply *bool) (err error) {
if args.ArgDispatcher == nil {
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
@@ -191,7 +191,7 @@ func (dS *DispatcherService) CacheSv1HasGroup(args *ArgsGetGroupWithApiKey,
}
// GetGroupItemIDs returns a list of itemIDs in a cache group
-func (dS *DispatcherService) CacheSv1GetGroupItemIDs(args *ArgsGetGroupWithApiKey,
+func (dS *DispatcherService) CacheSv1GetGroupItemIDs(args *utils.ArgsGetGroupWithArgDispatcher,
reply *[]string) (err error) {
if args.ArgDispatcher == nil {
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
@@ -208,7 +208,7 @@ func (dS *DispatcherService) CacheSv1GetGroupItemIDs(args *ArgsGetGroupWithApiKe
}
// RemoveGroup will remove a group and all items belonging to it from cache
-func (dS *DispatcherService) CacheSv1RemoveGroup(args *ArgsGetGroupWithApiKey,
+func (dS *DispatcherService) CacheSv1RemoveGroup(args *utils.ArgsGetGroupWithArgDispatcher,
reply *string) (err error) {
if args.ArgDispatcher == nil {
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
@@ -225,7 +225,7 @@ func (dS *DispatcherService) CacheSv1RemoveGroup(args *ArgsGetGroupWithApiKey,
}
// ReloadCache reloads cache from DB for a prefix or completely
-func (dS *DispatcherService) CacheSv1ReloadCache(args AttrReloadCacheWithApiKey, reply *string) (err error) {
+func (dS *DispatcherService) CacheSv1ReloadCache(args utils.AttrReloadCacheWithArgDispatcher, reply *string) (err error) {
if args.ArgDispatcher == nil {
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
}
@@ -241,7 +241,7 @@ func (dS *DispatcherService) CacheSv1ReloadCache(args AttrReloadCacheWithApiKey,
}
// LoadCache loads cache from DB for a prefix or completely
-func (dS *DispatcherService) CacheSv1LoadCache(args AttrReloadCacheWithApiKey, reply *string) (err error) {
+func (dS *DispatcherService) CacheSv1LoadCache(args utils.AttrReloadCacheWithArgDispatcher, reply *string) (err error) {
if args.ArgDispatcher == nil {
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
}
diff --git a/dispatchers/caches_it_test.go b/dispatchers/caches_it_test.go
index 5bf6ee5ce..388aa0ecb 100644
--- a/dispatchers/caches_it_test.go
+++ b/dispatchers/caches_it_test.go
@@ -84,7 +84,7 @@ func testDspChcLoadAfterFolder(t *testing.T) {
expStats[utils.CacheActions].Items = 1
expStats[utils.CacheDestinations].Items = 4
expStats[utils.CacheLoadIDs].Items = 17
- args := AttrCacheIDsWithApiKey{
+ args := utils.AttrCacheIDsWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
@@ -99,7 +99,7 @@ func testDspChcLoadAfterFolder(t *testing.T) {
}
reply := ""
// Simple test that command is executed without errors
- if err := dispEngine.RCP.Call(utils.CacheSv1LoadCache, AttrReloadCacheWithApiKey{
+ if err := dispEngine.RCP.Call(utils.CacheSv1LoadCache, utils.AttrReloadCacheWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
@@ -169,7 +169,7 @@ func testDspChcPrecacheStatus(t *testing.T) {
utils.CacheLoadIDs: utils.MetaReady,
}
- if err := dispEngine.RCP.Call(utils.CacheSv1PrecacheStatus, AttrCacheIDsWithApiKey{
+ if err := dispEngine.RCP.Call(utils.CacheSv1PrecacheStatus, utils.AttrCacheIDsWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
@@ -186,8 +186,8 @@ func testDspChcPrecacheStatus(t *testing.T) {
func testDspChcGetItemIDs(t *testing.T) {
var rcvKeys []string
expKeys := []string{"cgrates.org:DEFAULT"}
- argsAPI := ArgsGetCacheItemIDsWithApiKey{
- ArgsGetCacheItemIDs: engine.ArgsGetCacheItemIDs{
+ argsAPI := utils.ArgsGetCacheItemIDsWithArgDispatcher{
+ ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{
CacheID: utils.CacheChargerProfiles,
},
ArgDispatcher: &utils.ArgDispatcher{
@@ -208,8 +208,8 @@ func testDspChcGetItemIDs(t *testing.T) {
func testDspChcHasItem(t *testing.T) {
var reply bool
expected := true
- argsAPI := ArgsGetCacheItemWithApiKey{
- ArgsGetCacheItem: engine.ArgsGetCacheItem{
+ argsAPI := utils.ArgsGetCacheItemWithArgDispatcher{
+ ArgsGetCacheItem: utils.ArgsGetCacheItem{
CacheID: utils.CacheChargerProfiles,
ItemID: "cgrates.org:DEFAULT",
},
@@ -230,8 +230,8 @@ func testDspChcHasItem(t *testing.T) {
func testDspChcGetItemExpiryTime(t *testing.T) {
var reply time.Time
var expected time.Time
- argsAPI := ArgsGetCacheItemWithApiKey{
- ArgsGetCacheItem: engine.ArgsGetCacheItem{
+ argsAPI := utils.ArgsGetCacheItemWithArgDispatcher{
+ ArgsGetCacheItem: utils.ArgsGetCacheItem{
CacheID: utils.CacheChargerProfiles,
ItemID: "cgrates.org:DEFAULT",
},
@@ -251,7 +251,7 @@ func testDspChcGetItemExpiryTime(t *testing.T) {
func testDspChcReloadCache(t *testing.T) {
reply := ""
- if err := dispEngine.RCP.Call(utils.CacheSv1ReloadCache, AttrReloadCacheWithApiKey{
+ if err := dispEngine.RCP.Call(utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
@@ -267,8 +267,8 @@ func testDspChcReloadCache(t *testing.T) {
func testDspChcRemoveItem(t *testing.T) {
var reply bool
- argsAPI := ArgsGetCacheItemWithApiKey{
- ArgsGetCacheItem: engine.ArgsGetCacheItem{
+ argsAPI := utils.ArgsGetCacheItemWithArgDispatcher{
+ ArgsGetCacheItem: utils.ArgsGetCacheItem{
CacheID: utils.CacheChargerProfiles,
ItemID: "cgrates.org:DEFAULT",
},
@@ -299,7 +299,7 @@ func testDspChcRemoveItem(t *testing.T) {
func testDspChcClear(t *testing.T) {
reply := ""
- if err := dispEngine.RCP.Call(utils.CacheSv1Clear, AttrCacheIDsWithApiKey{
+ if err := dispEngine.RCP.Call(utils.CacheSv1Clear, utils.AttrCacheIDsWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
@@ -313,7 +313,7 @@ func testDspChcClear(t *testing.T) {
}
var rcvStats map[string]*ltcache.CacheStats
expStats := engine.GetDefaultEmptyCacheStats()
- if err := dispEngine.RCP.Call(utils.CacheSv1GetCacheStats, AttrCacheIDsWithApiKey{
+ if err := dispEngine.RCP.Call(utils.CacheSv1GetCacheStats, utils.AttrCacheIDsWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
@@ -329,7 +329,7 @@ func testDspChcClear(t *testing.T) {
func testDspChcFlush(t *testing.T) {
reply := ""
- if err := dispEngine.RCP.Call(utils.CacheSv1FlushCache, AttrReloadCacheWithApiKey{
+ if err := dispEngine.RCP.Call(utils.CacheSv1FlushCache, utils.AttrReloadCacheWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
@@ -346,7 +346,7 @@ func testDspChcFlush(t *testing.T) {
}
var rcvStats map[string]*ltcache.CacheStats
expStats := engine.GetDefaultEmptyCacheStats()
- if err := dispEngine.RCP.Call(utils.CacheSv1GetCacheStats, AttrCacheIDsWithApiKey{
+ if err := dispEngine.RCP.Call(utils.CacheSv1GetCacheStats, utils.AttrCacheIDsWithArgDispatcher{
ArgDispatcher: &utils.ArgDispatcher{
APIKey: utils.StringPointer("chc12345"),
},
diff --git a/dispatchers/utils.go b/dispatchers/utils.go
index 89304b2c3..e0145f019 100755
--- a/dispatchers/utils.go
+++ b/dispatchers/utils.go
@@ -24,7 +24,6 @@ import (
"github.com/cgrates/cgrates/servmanager"
- "github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/sessions"
"github.com/cgrates/cgrates/utils"
)
@@ -53,36 +52,6 @@ type ArgsReplicateSessionsWithApiKey struct {
sessions.ArgsReplicateSessions
}
-type ArgsGetCacheItemIDsWithApiKey struct {
- *utils.ArgDispatcher
- utils.TenantArg
- engine.ArgsGetCacheItemIDs
-}
-
-type ArgsGetCacheItemWithApiKey struct {
- *utils.ArgDispatcher
- utils.TenantArg
- engine.ArgsGetCacheItem
-}
-
-type AttrReloadCacheWithApiKey struct {
- *utils.ArgDispatcher
- utils.TenantArg
- utils.AttrReloadCache
-}
-
-type AttrCacheIDsWithApiKey struct {
- *utils.ArgDispatcher
- utils.TenantArg
- CacheIDs []string
-}
-
-type ArgsGetGroupWithApiKey struct {
- *utils.ArgDispatcher
- utils.TenantArg
- engine.ArgsGetGroup
-}
-
type AttrRemoteLockWithApiKey struct {
*utils.ArgDispatcher
utils.TenantArg
diff --git a/engine/caches.go b/engine/caches.go
index d31a9606d..03a7a3ae1 100644
--- a/engine/caches.go
+++ b/engine/caches.go
@@ -148,12 +148,7 @@ func (chS *CacheS) Call(serviceMethod string, args interface{}, reply interface{
return utils.RPCCall(chS, serviceMethod, args, reply)
}
-type ArgsGetCacheItemIDs struct {
- CacheID string
- ItemIDPrefix string
-}
-
-func (chS *CacheS) V1GetItemIDs(args *ArgsGetCacheItemIDs,
+func (chS *CacheS) V1GetItemIDs(args *utils.ArgsGetCacheItemIDsWithArgDispatcher,
reply *[]string) (err error) {
itmIDs := Cache.GetItemIDs(args.CacheID, args.ItemIDPrefix)
if len(itmIDs) == 0 {
@@ -163,18 +158,13 @@ func (chS *CacheS) V1GetItemIDs(args *ArgsGetCacheItemIDs,
return
}
-type ArgsGetCacheItem struct {
- CacheID string
- ItemID string
-}
-
-func (chS *CacheS) V1HasItem(args *ArgsGetCacheItem,
+func (chS *CacheS) V1HasItem(args *utils.ArgsGetCacheItemWithArgDispatcher,
reply *bool) (err error) {
*reply = Cache.HasItem(args.CacheID, args.ItemID)
return
}
-func (chS *CacheS) V1GetItemExpiryTime(args *ArgsGetCacheItem,
+func (chS *CacheS) V1GetItemExpiryTime(args *utils.ArgsGetCacheItemWithArgDispatcher,
reply *time.Time) (err error) {
expTime, has := Cache.GetItemExpiryTime(args.CacheID, args.ItemID)
if !has {
@@ -184,35 +174,35 @@ func (chS *CacheS) V1GetItemExpiryTime(args *ArgsGetCacheItem,
return
}
-func (chS *CacheS) V1RemoveItem(args *ArgsGetCacheItem,
+func (chS *CacheS) V1RemoveItem(args *utils.ArgsGetCacheItemWithArgDispatcher,
reply *string) (err error) {
Cache.Remove(args.CacheID, args.ItemID, true, utils.NonTransactional)
*reply = utils.OK
return
}
-func (chS *CacheS) V1Clear(cacheIDs []string,
+func (chS *CacheS) V1Clear(args *utils.AttrCacheIDsWithArgDispatcher,
reply *string) (err error) {
- Cache.Clear(cacheIDs)
+ Cache.Clear(args.CacheIDs)
*reply = utils.OK
return
}
-func (chS *CacheS) V1GetCacheStats(cacheIDs []string,
+func (chS *CacheS) V1GetCacheStats(args *utils.AttrCacheIDsWithArgDispatcher,
rply *map[string]*ltcache.CacheStats) (err error) {
- cs := Cache.GetCacheStats(cacheIDs)
+ cs := Cache.GetCacheStats(args.CacheIDs)
*rply = cs
return
}
-func (chS *CacheS) V1PrecacheStatus(cacheIDs []string, rply *map[string]string) (err error) {
- if len(cacheIDs) == 0 {
+func (chS *CacheS) V1PrecacheStatus(args *utils.AttrCacheIDsWithArgDispatcher, rply *map[string]string) (err error) {
+ if len(args.CacheIDs) == 0 {
for cacheID := range precachedPartitions {
- cacheIDs = append(cacheIDs, cacheID)
+ args.CacheIDs = append(args.CacheIDs, cacheID)
}
}
pCacheStatus := make(map[string]string)
- for _, cacheID := range cacheIDs {
+ for _, cacheID := range args.CacheIDs {
if _, has := chS.pcItems[cacheID]; !has {
return fmt.Errorf("unknown cacheID: %s", cacheID)
}
@@ -227,18 +217,13 @@ func (chS *CacheS) V1PrecacheStatus(cacheIDs []string, rply *map[string]string)
return
}
-type ArgsGetGroup struct {
- CacheID string
- GroupID string
-}
-
-func (chS *CacheS) V1HasGroup(args *ArgsGetGroup,
+func (chS *CacheS) V1HasGroup(args *utils.ArgsGetGroupWithArgDispatcher,
rply *bool) (err error) {
*rply = Cache.HasGroup(args.CacheID, args.GroupID)
return
}
-func (chS *CacheS) V1GetGroupItemIDs(args *ArgsGetGroup,
+func (chS *CacheS) V1GetGroupItemIDs(args *utils.ArgsGetGroupWithArgDispatcher,
rply *[]string) (err error) {
if has := Cache.HasGroup(args.CacheID, args.GroupID); !has {
return utils.ErrNotFound
@@ -247,7 +232,7 @@ func (chS *CacheS) V1GetGroupItemIDs(args *ArgsGetGroup,
return
}
-func (chS *CacheS) V1RemoveGroup(args *ArgsGetGroup,
+func (chS *CacheS) V1RemoveGroup(args *utils.ArgsGetGroupWithArgDispatcher,
rply *string) (err error) {
Cache.RemoveGroup(args.CacheID, args.GroupID, true, utils.NonTransactional)
*rply = utils.OK
@@ -261,7 +246,7 @@ func (chS *CacheS) reloadCache(chID string, IDs *[]string) error {
return chS.dm.CacheDataFromDB(chID, *IDs, true)
}
-func (chS *CacheS) V1ReloadCache(attrs utils.AttrReloadCache, reply *string) (err error) {
+func (chS *CacheS) V1ReloadCache(attrs utils.AttrReloadCacheWithArgDispatcher, reply *string) (err error) {
if attrs.FlushAll {
Cache.Clear(nil)
return
@@ -356,7 +341,7 @@ func (chS *CacheS) V1ReloadCache(attrs utils.AttrReloadCache, reply *string) (er
if err != nil {
return err
}
- cacheLoadIDs := populateCacheLoadIDs(loadIDs, attrs)
+ cacheLoadIDs := populateCacheLoadIDs(loadIDs, attrs.AttrReloadCache)
for key, val := range cacheLoadIDs {
Cache.Set(utils.CacheLoadIDs, key, val, nil,
cacheCommit(utils.NonTransactional), utils.NonTransactional)
@@ -373,7 +358,7 @@ func toStringSlice(in *[]string) []string {
return *in
}
-func (chS *CacheS) V1LoadCache(args utils.AttrReloadCache, reply *string) (err error) {
+func (chS *CacheS) V1LoadCache(args utils.AttrReloadCacheWithArgDispatcher, reply *string) (err error) {
if args.FlushAll {
Cache.Clear(nil)
}
@@ -407,7 +392,7 @@ func (chS *CacheS) V1LoadCache(args utils.AttrReloadCache, reply *string) (err e
if err != nil {
return err
}
- cacheLoadIDs := populateCacheLoadIDs(loadIDs, args)
+ cacheLoadIDs := populateCacheLoadIDs(loadIDs, args.AttrReloadCache)
for key, val := range cacheLoadIDs {
Cache.Set(utils.CacheLoadIDs, key, val, nil,
cacheCommit(utils.NonTransactional), utils.NonTransactional)
@@ -427,7 +412,7 @@ func flushCache(chID string, IDs *[]string) {
}
// FlushCache wipes out cache for a prefix or completely
-func (chS *CacheS) V1FlushCache(args utils.AttrReloadCache, reply *string) (err error) {
+func (chS *CacheS) V1FlushCache(args utils.AttrReloadCacheWithArgDispatcher, reply *string) (err error) {
if args.FlushAll {
Cache.Clear(nil)
*reply = utils.OK
@@ -459,7 +444,7 @@ func (chS *CacheS) V1FlushCache(args utils.AttrReloadCache, reply *string) (err
if err != nil {
return err
}
- cacheLoadIDs := populateCacheLoadIDs(loadIDs, args)
+ cacheLoadIDs := populateCacheLoadIDs(loadIDs, args.AttrReloadCache)
for key, val := range cacheLoadIDs {
Cache.Set(utils.CacheLoadIDs, key, val, nil,
cacheCommit(utils.NonTransactional), utils.NonTransactional)
diff --git a/engine/tpreader.go b/engine/tpreader.go
index e50018e0b..e7b4a9c58 100644
--- a/engine/tpreader.go
+++ b/engine/tpreader.go
@@ -2361,7 +2361,7 @@ func (tpr *TpReader) RemoveFromDatabase(verbose, disable_reverse bool) (err erro
return
}
-func (tpr *TpReader) ReloadCache(flush, verbose bool) (err error) {
+func (tpr *TpReader) ReloadCache(flush, verbose bool, argDispatcher *utils.ArgDispatcher) (err error) {
if tpr.cacheS == nil {
log.Print("Disabled automatic reload")
return
@@ -2390,31 +2390,34 @@ func (tpr *TpReader) ReloadCache(flush, verbose bool) (err error) {
aps, _ := tpr.GetLoadedIds(utils.ACTION_PLAN_PREFIX)
//compose Reload Cache argument
- cacheArgs := utils.AttrReloadCache{
- ArgsCache: utils.ArgsCache{
- DestinationIDs: &dstIds,
- ReverseDestinationIDs: &revDstIDs,
- RatingPlanIDs: &rplIds,
- RatingProfileIDs: &rpfIds,
- ActionIDs: &actIds,
- ActionPlanIDs: &aps,
- AccountActionPlanIDs: &aapIDs,
- SharedGroupIDs: &shgIds,
- ResourceProfileIDs: &rspIDs,
- ResourceIDs: &resIDs,
- ActionTriggerIDs: &aatIDs,
- StatsQueueIDs: &stqIDs,
- StatsQueueProfileIDs: &stqpIDs,
- ThresholdIDs: &trsIDs,
- ThresholdProfileIDs: &trspfIDs,
- FilterIDs: &flrIDs,
- SupplierProfileIDs: &spfIDs,
- AttributeProfileIDs: &apfIDs,
- ChargerProfileIDs: &chargerIDs,
- DispatcherProfileIDs: &dppIDs,
- DispatcherHostIDs: &dphIDs,
+ cacheArgs := utils.AttrReloadCacheWithArgDispatcher{
+ ArgDispatcher: argDispatcher,
+ AttrReloadCache: utils.AttrReloadCache{
+ ArgsCache: utils.ArgsCache{
+ DestinationIDs: &dstIds,
+ ReverseDestinationIDs: &revDstIDs,
+ RatingPlanIDs: &rplIds,
+ RatingProfileIDs: &rpfIds,
+ ActionIDs: &actIds,
+ ActionPlanIDs: &aps,
+ AccountActionPlanIDs: &aapIDs,
+ SharedGroupIDs: &shgIds,
+ ResourceProfileIDs: &rspIDs,
+ ResourceIDs: &resIDs,
+ ActionTriggerIDs: &aatIDs,
+ StatsQueueIDs: &stqIDs,
+ StatsQueueProfileIDs: &stqpIDs,
+ ThresholdIDs: &trsIDs,
+ ThresholdProfileIDs: &trspfIDs,
+ FilterIDs: &flrIDs,
+ SupplierProfileIDs: &spfIDs,
+ AttributeProfileIDs: &apfIDs,
+ ChargerProfileIDs: &chargerIDs,
+ DispatcherProfileIDs: &dppIDs,
+ DispatcherHostIDs: &dphIDs,
+ },
+ FlushAll: flush,
},
- FlushAll: flush,
}
if verbose {
@@ -2466,7 +2469,11 @@ func (tpr *TpReader) ReloadCache(flush, verbose bool) (err error) {
if verbose {
log.Print("Clearing indexes")
}
- if err = tpr.cacheS.Call(utils.CacheSv1Clear, cacheIDs, &reply); err != nil {
+ clearArgs := &utils.AttrCacheIDsWithArgDispatcher{
+ ArgDispatcher: argDispatcher,
+ CacheIDs: cacheIDs,
+ }
+ if err = tpr.cacheS.Call(utils.CacheSv1Clear, clearArgs, &reply); err != nil {
log.Printf("WARNING: Got error on cache clear: %s\n", err.Error())
}
@@ -2486,7 +2493,7 @@ func (tpr *TpReader) ReloadCache(flush, verbose bool) (err error) {
if err != nil {
return err
}
- cacheLoadIDs := populateCacheLoadIDs(loadIDs, cacheArgs)
+ cacheLoadIDs := populateCacheLoadIDs(loadIDs, cacheArgs.AttrReloadCache)
for key, val := range cacheLoadIDs {
Cache.Set(utils.CacheLoadIDs, key, val, nil,
cacheCommit(utils.NonTransactional), utils.NonTransactional)
diff --git a/utils/apitpdata.go b/utils/apitpdata.go
index 944660410..f35cec50f 100755
--- a/utils/apitpdata.go
+++ b/utils/apitpdata.go
@@ -678,17 +678,19 @@ type AttrRemCdrs struct {
}
type AttrLoadTpFromFolder struct {
- FolderPath string // Take files from folder absolute path
- DryRun bool // Do not write to database but parse only
- FlushDb bool // Flush previous data before loading new one
- Validate bool // Run structural checks on data
+ FolderPath string // Take files from folder absolute path
+ DryRun bool // Do not write to database but parse only
+ FlushDb bool // Flush previous data before loading new one
+ Validate bool // Run structural checks on data
+ ArgDispatcher *ArgDispatcher
}
type AttrImportTPFromFolder struct {
- TPid string
- FolderPath string
- RunId string
- CsvSeparator string
+ TPid string
+ FolderPath string
+ RunId string
+ CsvSeparator string
+ ArgDispatcher *ArgDispatcher
}
type AttrGetDestination struct {
@@ -1369,3 +1371,48 @@ type RPCCDRsFilterWithArgDispatcher struct {
*RPCCDRsFilter
*TenantWithArgDispatcher
}
+
+type ArgsGetCacheItemIDsWithArgDispatcher struct {
+ *ArgDispatcher
+ TenantArg
+ ArgsGetCacheItemIDs
+}
+
+type ArgsGetCacheItemWithArgDispatcher struct {
+ *ArgDispatcher
+ TenantArg
+ ArgsGetCacheItem
+}
+
+type AttrReloadCacheWithArgDispatcher struct {
+ *ArgDispatcher
+ TenantArg
+ AttrReloadCache
+}
+
+type AttrCacheIDsWithArgDispatcher struct {
+ *ArgDispatcher
+ TenantArg
+ CacheIDs []string
+}
+
+type ArgsGetGroupWithArgDispatcher struct {
+ *ArgDispatcher
+ TenantArg
+ ArgsGetGroup
+}
+
+type ArgsGetCacheItemIDs struct {
+ CacheID string
+ ItemIDPrefix string
+}
+
+type ArgsGetCacheItem struct {
+ CacheID string
+ ItemID string
+}
+
+type ArgsGetGroup struct {
+ CacheID string
+ GroupID string
+}