Send furder Opts from APIer to CacheS when do set/remove operations

This commit is contained in:
TeoV
2020-07-30 14:07:04 +03:00
committed by Dan Christian Bogos
parent 59e945b017
commit 92d5436e6b
14 changed files with 45 additions and 33 deletions

View File

@@ -1340,7 +1340,7 @@ func (apierSv1 *APIerSv1) ReplayFailedPosts(args *ArgsReplyFailedPosts, reply *s
// CallCache caching the item based on cacheopt
// visible in APIerSv2
func (apierSv1 *APIerSv1) CallCache(cacheOpt string, args utils.ArgsGetCacheItem) (err error) {
func (apierSv1 *APIerSv1) CallCache(cacheOpt string, args utils.ArgsGetCacheItem, opts map[string]interface{}) (err error) {
var reply string
switch cacheOpt {
case utils.META_NONE:
@@ -1348,25 +1348,26 @@ func (apierSv1 *APIerSv1) CallCache(cacheOpt string, args utils.ArgsGetCacheItem
case utils.MetaReload:
if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil,
utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{
ArgsCache: composeArgsReload(args)}, &reply); err != nil {
ArgsCache: composeArgsReload(args), Opts: opts}, &reply); err != nil {
return err
}
case utils.MetaLoad:
if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil,
utils.CacheSv1LoadCache, utils.AttrReloadCacheWithOpts{
ArgsCache: composeArgsReload(args)}, &reply); err != nil {
ArgsCache: composeArgsReload(args), Opts: opts}, &reply); err != nil {
return err
}
case utils.MetaRemove:
if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil,
utils.CacheSv1RemoveItem,
&utils.ArgsGetCacheItemWithOpts{ArgsGetCacheItem: args}, &reply); err != nil {
&utils.ArgsGetCacheItemWithOpts{ArgsGetCacheItem: args, Opts: opts}, &reply); err != nil {
return err
}
case utils.MetaClear:
if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil,
utils.CacheSv1Clear, &utils.AttrCacheIDsWithOpts{
CacheIDs: []string{args.CacheID},
Opts: opts,
}, &reply); err != nil {
return err
}

View File

@@ -115,7 +115,7 @@ func (apierSv1 *APIerSv1) SetAttributeProfile(alsWrp *AttributeWithCache, reply
CacheID: utils.CacheAttributeProfiles,
ItemID: alsWrp.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(alsWrp.Cache), args); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(alsWrp.Cache), args, alsWrp.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
@@ -139,7 +139,7 @@ func (apierSv1 *APIerSv1) RemoveAttributeProfile(arg *utils.TenantIDWithCache, r
CacheID: utils.CacheAttributeProfiles,
ItemID: utils.ConcatenatedKey(arg.Tenant, arg.ID),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), args); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), args, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK

View File

@@ -62,6 +62,7 @@ func (apierSv1 *APIerSv1) GetChargerProfileIDs(args *utils.TenantArgWithPaginato
type ChargerWithCache struct {
*engine.ChargerProfile
Cache *string
Opts map[string]interface{}
}
//SetChargerProfile add/update a new Charger Profile
@@ -81,7 +82,7 @@ func (apierSv1 *APIerSv1) SetChargerProfile(arg *ChargerWithCache, reply *string
CacheID: utils.CacheChargerProfiles,
ItemID: arg.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
@@ -106,7 +107,7 @@ func (apierSv1 *APIerSv1) RemoveChargerProfile(arg *utils.TenantIDWithCache, rep
CacheID: utils.CacheChargerProfiles,
ItemID: arg.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK

View File

@@ -67,6 +67,7 @@ func (apierSv1 *APIerSv1) GetDispatcherProfileIDs(tenantArg *utils.TenantArgWith
type DispatcherWithCache struct {
*engine.DispatcherProfile
Cache *string
Opts map[string]interface{}
}
//SetDispatcherProfile add/update a new Dispatcher Profile
@@ -86,7 +87,7 @@ func (apierSv1 *APIerSv1) SetDispatcherProfile(args *DispatcherWithCache, reply
CacheID: utils.CacheDispatcherProfiles,
ItemID: args.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache, args.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
@@ -111,7 +112,7 @@ func (apierSv1 *APIerSv1) RemoveDispatcherProfile(arg *utils.TenantIDWithCache,
CacheID: utils.CacheDispatcherProfiles,
ItemID: arg.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
@@ -156,6 +157,7 @@ func (apierSv1 *APIerSv1) GetDispatcherHostIDs(tenantArg *utils.TenantArgWithPag
type DispatcherHostWithCache struct {
*engine.DispatcherHost
Cache *string
Opts map[string]interface{}
}
//SetDispatcherHost add/update a new Dispatcher Host
@@ -175,7 +177,7 @@ func (apierSv1 *APIerSv1) SetDispatcherHost(args *DispatcherHostWithCache, reply
CacheID: utils.CacheDispatcherHosts,
ItemID: args.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache, args.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
@@ -200,7 +202,7 @@ func (apierSv1 *APIerSv1) RemoveDispatcherHost(arg *utils.TenantIDWithCache, rep
CacheID: utils.CacheDispatcherHosts,
ItemID: arg.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK

View File

@@ -28,6 +28,7 @@ import (
type FilterWithCache struct {
*engine.Filter
Cache *string
Opts map[string]interface{}
}
//SetFilter add a new Filter
@@ -47,7 +48,7 @@ func (apierSv1 *APIerSv1) SetFilter(arg *FilterWithCache, reply *string) error {
CacheID: utils.CacheFilters,
ItemID: arg.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
@@ -105,7 +106,7 @@ func (apierSv1 *APIerSv1) RemoveFilter(arg *utils.TenantIDWithCache, reply *stri
CacheID: utils.CacheFilters,
ItemID: arg.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK

View File

@@ -104,7 +104,7 @@ func (apierSv1 *APIerSv1) SetRateProfile(rPrf *RateProfileWithCache, reply *stri
CacheID: utils.CacheRateProfiles,
ItemID: rPrf.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(rPrf.Cache), args); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(rPrf.Cache), args, rPrf.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
@@ -128,7 +128,7 @@ func (apierSv1 *APIerSv1) SetRateProfileRates(rPrf *RateProfileWithCache, reply
CacheID: utils.CacheRateProfiles,
ItemID: rPrf.TenantID(),
}
if err = apierSv1.CallCache(GetCacheOpt(rPrf.Cache), args); err != nil {
if err = apierSv1.CallCache(GetCacheOpt(rPrf.Cache), args, rPrf.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
@@ -140,6 +140,7 @@ type RemoveRPrfRates struct {
ID string
RateIDs []string
Cache *string
Opts map[string]interface{}
}
func (apierSv1 *APIerSv1) RemoveRateProfileRates(args *RemoveRPrfRates, reply *string) (err error) {
@@ -157,7 +158,7 @@ func (apierSv1 *APIerSv1) RemoveRateProfileRates(args *RemoveRPrfRates, reply *s
CacheID: utils.CacheRateProfiles,
ItemID: utils.ConcatenatedKey(args.Tenant, args.ID),
}
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argsCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argsCache, args.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
@@ -181,7 +182,7 @@ func (apierSv1 *APIerSv1) RemoveRateProfile(arg *utils.TenantIDWithCache, reply
CacheID: utils.CacheRateProfiles,
ItemID: utils.ConcatenatedKey(arg.Tenant, arg.ID),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), args); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), args, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK

View File

@@ -101,6 +101,7 @@ func (apierSv1 *APIerSv1) GetResourceProfileIDs(args utils.TenantArgWithPaginato
type ResourceWithCache struct {
*engine.ResourceProfile
Cache *string
Opts map[string]interface{}
}
//SetResourceProfile adds a new resource configuration
@@ -124,7 +125,7 @@ func (apierSv1 *APIerSv1) SetResourceProfile(arg *ResourceWithCache, reply *stri
CacheID: utils.CacheResourceProfiles,
ItemID: arg.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
//add the resource only if it's not present
@@ -142,7 +143,7 @@ func (apierSv1 *APIerSv1) SetResourceProfile(arg *ResourceWithCache, reply *stri
CacheID: utils.CacheResources,
ItemID: arg.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
}
@@ -164,7 +165,7 @@ func (apierSv1 *APIerSv1) RemoveResourceProfile(arg *utils.TenantIDWithCache, re
CacheID: utils.CacheResourceProfiles,
ItemID: arg.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
if err := apierSv1.DataManager.RemoveResource(arg.Tenant, arg.ID, utils.NonTransactional); err != nil {
@@ -181,7 +182,7 @@ func (apierSv1 *APIerSv1) RemoveResourceProfile(arg *utils.TenantIDWithCache, re
CacheID: utils.CacheResources,
ItemID: arg.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK

View File

@@ -62,6 +62,7 @@ func (apierSv1 *APIerSv1) GetRouteProfileIDs(args *utils.TenantArgWithPaginator,
type RouteWithCache struct {
*engine.RouteProfile
Cache *string
Opts map[string]interface{}
}
//SetRouteProfile add a new Route configuration
@@ -81,7 +82,7 @@ func (apierSv1 *APIerSv1) SetRouteProfile(args *RouteWithCache, reply *string) e
CacheID: utils.CacheRouteProfiles,
ItemID: args.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache, args.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
@@ -105,7 +106,7 @@ func (apierSv1 *APIerSv1) RemoveRouteProfile(args *utils.TenantIDWithCache, repl
CacheID: utils.CacheRouteProfiles,
ItemID: args.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache, args.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK

View File

@@ -79,7 +79,7 @@ func (apierSv1 *APIerSv1) SetStatQueueProfile(arg *engine.StatQueueWithCache, re
CacheID: utils.CacheStatQueueProfiles,
ItemID: arg.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
if has, err := apierSv1.DataManager.HasData(utils.StatQueuePrefix, arg.ID, arg.Tenant); err != nil {
@@ -102,7 +102,7 @@ func (apierSv1 *APIerSv1) SetStatQueueProfile(arg *engine.StatQueueWithCache, re
CacheID: utils.CacheStatQueues,
ItemID: arg.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(arg.Cache), argCache, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
}
@@ -124,7 +124,7 @@ func (apierSv1 *APIerSv1) RemoveStatQueueProfile(args *utils.TenantIDWithCache,
CacheID: utils.CacheStatQueueProfiles,
ItemID: args.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache, args.Opts); err != nil {
return utils.APIErrorHandler(err)
}
if err := apierSv1.DataManager.RemoveStatQueue(args.Tenant, args.ID, utils.NonTransactional); err != nil {
@@ -141,7 +141,7 @@ func (apierSv1 *APIerSv1) RemoveStatQueueProfile(args *utils.TenantIDWithCache,
CacheID: utils.CacheStatQueues,
ItemID: args.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache, args.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK

View File

@@ -131,7 +131,7 @@ func (apierSv1 *APIerSv1) SetThresholdProfile(args *engine.ThresholdWithCache, r
CacheID: utils.CacheThresholdProfiles,
ItemID: args.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache, args.Opts); err != nil {
return utils.APIErrorHandler(err)
}
@@ -146,7 +146,7 @@ func (apierSv1 *APIerSv1) SetThresholdProfile(args *engine.ThresholdWithCache, r
CacheID: utils.CacheThresholds,
ItemID: args.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache, args.Opts); err != nil {
return utils.APIErrorHandler(err)
}
}
@@ -168,7 +168,7 @@ func (apierSv1 *APIerSv1) RemoveThresholdProfile(args *utils.TenantIDWithCache,
CacheID: utils.CacheThresholdProfiles,
ItemID: args.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache, args.Opts); err != nil {
return utils.APIErrorHandler(err)
}
if err := apierSv1.DataManager.RemoveThreshold(args.Tenant, args.ID, utils.NonTransactional); err != nil {
@@ -185,7 +185,7 @@ func (apierSv1 *APIerSv1) RemoveThresholdProfile(args *utils.TenantIDWithCache,
CacheID: utils.CacheThresholds,
ItemID: args.TenantID(),
}
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache); err != nil {
if err := apierSv1.CallCache(GetCacheOpt(args.Cache), argCache, args.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK

View File

@@ -29,6 +29,7 @@ import (
type AttributeWithCache struct {
*engine.ExternalAttributeProfile
Cache *string
Opts map[string]interface{}
}
//SetAttributeProfile add/update a new Attribute Profile
@@ -54,7 +55,7 @@ func (APIerSv2 *APIerSv2) SetAttributeProfile(arg *AttributeWithCache, reply *st
}
if err := APIerSv2.APIerSv1.CallCache(
v1.GetCacheOpt(arg.Cache),
args); err != nil {
args, arg.Opts); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK

View File

@@ -53,6 +53,7 @@ type StatQueueProfileWithOpts struct {
type StatQueueWithCache struct {
*StatQueueProfile
Cache *string
Opts map[string]interface{}
}
func (sqp *StatQueueProfile) TenantID() string {

View File

@@ -33,6 +33,7 @@ import (
type ThresholdWithCache struct {
*ThresholdProfile
Cache *string
Opts map[string]interface{}
}
// ThresholdProfileWithOpts is used in replicatorV1 for dispatcher

View File

@@ -773,6 +773,7 @@ type TenantIDWithCache struct {
Tenant string
ID string
Cache *string
Opts map[string]interface{}
}
func (tID *TenantIDWithCache) TenantID() string {