From 92d5436e6b7e701bdd161ea687743f017dfcffbb Mon Sep 17 00:00:00 2001 From: TeoV Date: Thu, 30 Jul 2020 14:07:04 +0300 Subject: [PATCH] Send furder Opts from APIer to CacheS when do set/remove operations --- apier/v1/apier.go | 9 +++++---- apier/v1/attributes.go | 4 ++-- apier/v1/chargers.go | 5 +++-- apier/v1/dispatcher.go | 10 ++++++---- apier/v1/filters.go | 5 +++-- apier/v1/rateprofiles.go | 9 +++++---- apier/v1/resourcesv1.go | 9 +++++---- apier/v1/routes.go | 5 +++-- apier/v1/stats.go | 8 ++++---- apier/v1/thresholds.go | 8 ++++---- apier/v2/attributes.go | 3 ++- engine/libstats.go | 1 + engine/thresholds.go | 1 + utils/coreutils.go | 1 + 14 files changed, 45 insertions(+), 33 deletions(-) diff --git a/apier/v1/apier.go b/apier/v1/apier.go index 1fca6355b..bcfd228e7 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -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 } diff --git a/apier/v1/attributes.go b/apier/v1/attributes.go index a331af1ed..f1fe2f0e4 100644 --- a/apier/v1/attributes.go +++ b/apier/v1/attributes.go @@ -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 diff --git a/apier/v1/chargers.go b/apier/v1/chargers.go index 18356f316..605d93817 100644 --- a/apier/v1/chargers.go +++ b/apier/v1/chargers.go @@ -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 diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index 77a315ae2..83e783442 100755 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -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 diff --git a/apier/v1/filters.go b/apier/v1/filters.go index b146a35e5..4c9c21a37 100644 --- a/apier/v1/filters.go +++ b/apier/v1/filters.go @@ -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 diff --git a/apier/v1/rateprofiles.go b/apier/v1/rateprofiles.go index 259405dab..275e06d13 100644 --- a/apier/v1/rateprofiles.go +++ b/apier/v1/rateprofiles.go @@ -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 diff --git a/apier/v1/resourcesv1.go b/apier/v1/resourcesv1.go index 7f6264fbb..0d45118ff 100644 --- a/apier/v1/resourcesv1.go +++ b/apier/v1/resourcesv1.go @@ -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 diff --git a/apier/v1/routes.go b/apier/v1/routes.go index 3db3f18fd..facb3e254 100644 --- a/apier/v1/routes.go +++ b/apier/v1/routes.go @@ -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 diff --git a/apier/v1/stats.go b/apier/v1/stats.go index f53dd3cb1..b9069bb8f 100644 --- a/apier/v1/stats.go +++ b/apier/v1/stats.go @@ -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 diff --git a/apier/v1/thresholds.go b/apier/v1/thresholds.go index be1c95c5f..1effd84d4 100644 --- a/apier/v1/thresholds.go +++ b/apier/v1/thresholds.go @@ -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 diff --git a/apier/v2/attributes.go b/apier/v2/attributes.go index e59613aee..de73c421a 100644 --- a/apier/v2/attributes.go +++ b/apier/v2/attributes.go @@ -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 diff --git a/engine/libstats.go b/engine/libstats.go index 943fa1fc4..d316aacd8 100644 --- a/engine/libstats.go +++ b/engine/libstats.go @@ -53,6 +53,7 @@ type StatQueueProfileWithOpts struct { type StatQueueWithCache struct { *StatQueueProfile Cache *string + Opts map[string]interface{} } func (sqp *StatQueueProfile) TenantID() string { diff --git a/engine/thresholds.go b/engine/thresholds.go index b2fea56f6..1fc2e9f9e 100644 --- a/engine/thresholds.go +++ b/engine/thresholds.go @@ -33,6 +33,7 @@ import ( type ThresholdWithCache struct { *ThresholdProfile Cache *string + Opts map[string]interface{} } // ThresholdProfileWithOpts is used in replicatorV1 for dispatcher diff --git a/utils/coreutils.go b/utils/coreutils.go index 7b56b765a..0d9e38443 100644 --- a/utils/coreutils.go +++ b/utils/coreutils.go @@ -773,6 +773,7 @@ type TenantIDWithCache struct { Tenant string ID string Cache *string + Opts map[string]interface{} } func (tID *TenantIDWithCache) TenantID() string {