From b88045872fbc9bb0553ad0438eee619449760795 Mon Sep 17 00:00:00 2001 From: arberkatellari Date: Tue, 9 Jan 2024 09:42:48 -0500 Subject: [PATCH] Optimise caching_delay --- apier/v1/apier.go | 14 +++++++------- apier/v1/attributes.go | 4 ++-- apier/v1/chargers.go | 4 ++-- apier/v1/dispatcher.go | 4 ++-- apier/v1/replicator.go | 26 +++++++++++++------------- apier/v1/resourcesv1.go | 4 ++-- apier/v1/routes.go | 4 ++-- apier/v1/stats.go | 4 ++-- apier/v1/thresholds.go | 4 ++-- apier/v2/apier.go | 4 ++-- apier/v2/attributes.go | 2 +- cmd/cgr-loader/cgr-loader.go | 2 +- loaders/loader.go | 4 ++-- 13 files changed, 40 insertions(+), 40 deletions(-) diff --git a/apier/v1/apier.go b/apier/v1/apier.go index d7907d987..44211aa6b 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -338,8 +338,8 @@ func (apierSv1 *APIerSv1) LoadRatingProfile(ctx *context.Context, attrs *utils.T // delay if needed before cache reload if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache reload for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) if err = dbReader.ReloadCache(config.CgrConfig().GeneralCfg().DefaultCaching, true, make(map[string]any), attrs.Tenant); err != nil { return utils.NewErrServerError(err) } @@ -415,8 +415,8 @@ func (apierSv1 *APIerSv1) LoadTariffPlanFromStorDb(ctx *context.Context, attrs * // delay if needed before cache reload if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache reload for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) // reload cache utils.Logger.Info("APIerSv1.LoadTariffPlanFromStorDb, reloading cache.") if err := dbReader.ReloadCache(caching, true, attrs.APIOpts, apierSv1.Config.GeneralCfg().DefaultTenant); err != nil { @@ -519,8 +519,8 @@ func (apierSv1 *APIerSv1) SetRatingProfile(ctx *context.Context, attrs *utils.At // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) if err := apierSv1.CallCache(utils.IfaceAsString(attrs.APIOpts[utils.CacheOpt]), attrs.Tenant, utils.CacheRatingProfiles, keyID, utils.EmptyString, nil, nil, attrs.APIOpts); err != nil { return utils.APIErrorHandler(err) } @@ -1107,8 +1107,8 @@ func (apierSv1 *APIerSv1) LoadTariffPlanFromFolder(ctx *context.Context, attrs * // delay if needed before cache reload if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache reload for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) // reload cache utils.Logger.Info("APIerSv1.LoadTariffPlanFromFolder, reloading cache.") if err := loader.ReloadCache(caching, true, attrs.APIOpts, apierSv1.Config.GeneralCfg().DefaultTenant); err != nil { @@ -1184,8 +1184,8 @@ func (apierSv1 *APIerSv1) RemoveTPFromFolder(ctx *context.Context, attrs *utils. // delay if needed before cache reload if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache reload for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) // reload cache utils.Logger.Info("APIerSv1.RemoveTPFromFolder, reloading cache.") if err := loader.ReloadCache(caching, true, attrs.APIOpts, apierSv1.Config.GeneralCfg().DefaultTenant); err != nil { @@ -1241,8 +1241,8 @@ func (apierSv1 *APIerSv1) RemoveTPFromStorDB(ctx *context.Context, attrs *AttrLo // delay if needed before cache reload if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache reload for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) // reload cache utils.Logger.Info("APIerSv1.RemoveTPFromStorDB, reloading cache.") if err := dbReader.ReloadCache(caching, true, attrs.APIOpts, apierSv1.Config.GeneralCfg().DefaultTenant); err != nil { @@ -1309,8 +1309,8 @@ func (apierSv1 *APIerSv1) RemoveRatingProfile(ctx *context.Context, attr *AttrRe // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) if err := apierSv1.CallCache(utils.IfaceAsString(attr.APIOpts[utils.CacheOpt]), attr.Tenant, utils.CacheRatingProfiles, keyID, utils.EmptyString, nil, nil, attr.APIOpts); err != nil { return utils.APIErrorHandler(err) } diff --git a/apier/v1/attributes.go b/apier/v1/attributes.go index b3b5e6c2f..e047a7372 100644 --- a/apier/v1/attributes.go +++ b/apier/v1/attributes.go @@ -119,8 +119,8 @@ func (apierSv1 *APIerSv1) SetAttributeProfile(ctx *context.Context, alsWrp *engi // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) if err := apierSv1.CallCache(utils.IfaceAsString(alsWrp.APIOpts[utils.CacheOpt]), alsWrp.Tenant, utils.CacheAttributeProfiles, alsWrp.TenantID(), utils.EmptyString, &alsWrp.FilterIDs, alsWrp.Contexts, alsWrp.APIOpts); err != nil { return utils.APIErrorHandler(err) @@ -148,8 +148,8 @@ func (apierSv1 *APIerSv1) RemoveAttributeProfile(ctx *context.Context, arg *util // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) if err := apierSv1.CallCache(utils.IfaceAsString(arg.APIOpts[utils.CacheOpt]), tnt, utils.CacheAttributeProfiles, utils.ConcatenatedKey(tnt, arg.ID), utils.EmptyString, nil, nil, arg.APIOpts); err != nil { return utils.APIErrorHandler(err) diff --git a/apier/v1/chargers.go b/apier/v1/chargers.go index de9dd1174..e7ff5af91 100644 --- a/apier/v1/chargers.go +++ b/apier/v1/chargers.go @@ -89,8 +89,8 @@ func (apierSv1 *APIerSv1) SetChargerProfile(ctx *context.Context, arg *ChargerWi // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) //handle caching for ChargerProfile if err := apierSv1.CallCache(utils.IfaceAsString(arg.APIOpts[utils.CacheOpt]), arg.Tenant, utils.CacheChargerProfiles, arg.TenantID(), utils.EmptyString, &arg.FilterIDs, nil, arg.APIOpts); err != nil { @@ -120,8 +120,8 @@ func (apierSv1 *APIerSv1) RemoveChargerProfile(ctx *context.Context, arg *utils. // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) //handle caching for ChargerProfile if err := apierSv1.CallCache(utils.IfaceAsString(arg.APIOpts[utils.CacheOpt]), tnt, utils.CacheChargerProfiles, utils.ConcatenatedKey(tnt, arg.ID), utils.EmptyString, nil, nil, arg.APIOpts); err != nil { diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index 9adcf6b9e..eb880f621 100644 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -93,8 +93,8 @@ func (apierSv1 *APIerSv1) SetDispatcherProfile(ctx *context.Context, args *Dispa // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) //handle caching for DispatcherProfile if err := apierSv1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), args.Tenant, utils.CacheDispatcherProfiles, args.TenantID(), utils.EmptyString, &args.FilterIDs, args.Subsystems, args.APIOpts); err != nil { @@ -136,8 +136,8 @@ func (apierSv1 *APIerSv1) RemoveDispatcherProfile(ctx *context.Context, arg *uti // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) //handle caching for DispatcherProfile if err := apierSv1.CallCache(utils.IfaceAsString(arg.APIOpts[utils.CacheOpt]), tnt, utils.CacheDispatcherProfiles, utils.ConcatenatedKey(tnt, arg.ID), utils.EmptyString, nil, nil, arg.APIOpts); err != nil { diff --git a/apier/v1/replicator.go b/apier/v1/replicator.go index 925753701..55e7be64f 100644 --- a/apier/v1/replicator.go +++ b/apier/v1/replicator.go @@ -380,8 +380,8 @@ func (rplSv1 *ReplicatorSv1) SetThresholdProfile(ctx *context.Context, th *engin // delay if needed before cache call if rplSv1.v1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.Config.GeneralCfg().CachingDelay)) + time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) } - time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) if err = rplSv1.v1.CallCache(utils.IfaceAsString(th.APIOpts[utils.CacheOpt]), th.Tenant, utils.CacheThresholdProfiles, th.TenantID(), utils.EmptyString, &th.FilterIDs, nil, th.APIOpts); err != nil { return @@ -411,8 +411,8 @@ func (rplSv1 *ReplicatorSv1) SetStatQueueProfile(ctx *context.Context, sq *engin // delay if needed before cache call if rplSv1.v1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.Config.GeneralCfg().CachingDelay)) + time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) } - time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) if err = rplSv1.v1.CallCache(utils.IfaceAsString(sq.APIOpts[utils.CacheOpt]), sq.Tenant, utils.CacheStatQueueProfiles, sq.TenantID(), utils.EmptyString, &sq.FilterIDs, nil, sq.APIOpts); err != nil { return @@ -468,8 +468,8 @@ func (rplSv1 *ReplicatorSv1) SetResourceProfile(ctx *context.Context, rs *engine // delay if needed before cache call if rplSv1.v1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.Config.GeneralCfg().CachingDelay)) + time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) } - time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) if err = rplSv1.v1.CallCache(utils.IfaceAsString(rs.APIOpts[utils.CacheOpt]), rs.Tenant, utils.CacheResourceProfiles, rs.TenantID(), utils.EmptyString, &rs.FilterIDs, nil, rs.APIOpts); err != nil { return @@ -551,8 +551,8 @@ func (rplSv1 *ReplicatorSv1) SetRatingProfile(ctx *context.Context, rp *engine.R // delay if needed before cache call if rplSv1.v1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.Config.GeneralCfg().CachingDelay)) + time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) } - time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) if err = rplSv1.v1.CallCache(utils.IfaceAsString(rp.APIOpts[utils.CacheOpt]), rp.Tenant, utils.CacheRatingProfiles, rp.Id, utils.EmptyString, nil, nil, rp.APIOpts); err != nil { return @@ -569,8 +569,8 @@ func (rplSv1 *ReplicatorSv1) SetRouteProfile(ctx *context.Context, sp *engine.Ro // delay if needed before cache call if rplSv1.v1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.Config.GeneralCfg().CachingDelay)) + time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) } - time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) if err = rplSv1.v1.CallCache(utils.IfaceAsString(sp.APIOpts[utils.CacheOpt]), sp.Tenant, utils.CacheRouteProfiles, sp.TenantID(), utils.EmptyString, &sp.FilterIDs, nil, sp.APIOpts); err != nil { return @@ -587,8 +587,8 @@ func (rplSv1 *ReplicatorSv1) SetAttributeProfile(ctx *context.Context, ap *engin // delay if needed before cache call if rplSv1.v1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.Config.GeneralCfg().CachingDelay)) + time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) } - time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) if err = rplSv1.v1.CallCache(utils.IfaceAsString(ap.APIOpts[utils.CacheOpt]), ap.Tenant, utils.CacheAttributeProfiles, ap.TenantID(), utils.EmptyString, &ap.FilterIDs, ap.Contexts, ap.APIOpts); err != nil { return @@ -605,8 +605,8 @@ func (rplSv1 *ReplicatorSv1) SetChargerProfile(ctx *context.Context, cp *engine. // delay if needed before cache call if rplSv1.v1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.Config.GeneralCfg().CachingDelay)) + time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) } - time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) if err = rplSv1.v1.CallCache(utils.IfaceAsString(cp.APIOpts[utils.CacheOpt]), cp.Tenant, utils.CacheChargerProfiles, cp.TenantID(), utils.EmptyString, &cp.FilterIDs, nil, cp.APIOpts); err != nil { return @@ -623,8 +623,8 @@ func (rplSv1 *ReplicatorSv1) SetDispatcherProfile(ctx *context.Context, dpp *eng // delay if needed before cache call if rplSv1.v1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.Config.GeneralCfg().CachingDelay)) + time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) } - time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) if err = rplSv1.v1.CallCache(utils.IfaceAsString(dpp.APIOpts[utils.CacheOpt]), dpp.Tenant, utils.CacheDispatcherProfiles, dpp.TenantID(), utils.EmptyString, &dpp.FilterIDs, dpp.Subsystems, dpp.APIOpts); err != nil { return @@ -776,8 +776,8 @@ func (rplSv1 *ReplicatorSv1) RemoveThresholdProfile(ctx *context.Context, args * // delay if needed before cache call if rplSv1.v1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.Config.GeneralCfg().CachingDelay)) + time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) } - time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) if err = rplSv1.v1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), args.Tenant, utils.CacheThresholdProfiles, args.TenantID.TenantID(), utils.EmptyString, nil, nil, args.APIOpts); err != nil { return @@ -794,8 +794,8 @@ func (rplSv1 *ReplicatorSv1) RemoveStatQueueProfile(ctx *context.Context, args * // delay if needed before cache call if rplSv1.v1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.Config.GeneralCfg().CachingDelay)) + time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) } - time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) if err = rplSv1.v1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), args.Tenant, utils.CacheStatQueueProfiles, args.TenantID.TenantID(), utils.EmptyString, nil, nil, args.APIOpts); err != nil { return @@ -838,8 +838,8 @@ func (rplSv1 *ReplicatorSv1) RemoveResourceProfile(ctx *context.Context, args *u // delay if needed before cache call if rplSv1.v1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.Config.GeneralCfg().CachingDelay)) + time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) } - time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) if err = rplSv1.v1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), args.Tenant, utils.CacheResourceProfiles, args.TenantID.TenantID(), utils.EmptyString, nil, nil, args.APIOpts); err != nil { return @@ -934,8 +934,8 @@ func (rplSv1 *ReplicatorSv1) RemoveRatingProfile(ctx *context.Context, id *utils // delay if needed before cache call if rplSv1.v1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.Config.GeneralCfg().CachingDelay)) + time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) } - time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) if err = rplSv1.v1.CallCache(utils.IfaceAsString(id.APIOpts[utils.CacheOpt]), id.Tenant, utils.CacheRatingProfiles, id.Arg, utils.EmptyString, nil, nil, id.APIOpts); err != nil { return @@ -952,8 +952,8 @@ func (rplSv1 *ReplicatorSv1) RemoveRouteProfile(ctx *context.Context, args *util // delay if needed before cache call if rplSv1.v1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", rplSv1.v1.Config.GeneralCfg().CachingDelay)) + time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) } - time.Sleep(rplSv1.v1.Config.GeneralCfg().CachingDelay) if err = rplSv1.v1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), args.Tenant, utils.CacheRouteProfiles, args.TenantID.TenantID(), utils.EmptyString, nil, nil, args.APIOpts); err != nil { return diff --git a/apier/v1/resourcesv1.go b/apier/v1/resourcesv1.go index 9b0ee3bfe..9c52e84c4 100644 --- a/apier/v1/resourcesv1.go +++ b/apier/v1/resourcesv1.go @@ -131,8 +131,8 @@ func (apierSv1 *APIerSv1) SetResourceProfile(ctx *context.Context, arg *engine.R // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) //handle caching for ResourceProfile if err = apierSv1.CallCache(utils.IfaceAsString(arg.APIOpts[utils.CacheOpt]), arg.Tenant, utils.CacheResourceProfiles, arg.TenantID(), utils.EmptyString, &arg.FilterIDs, nil, arg.APIOpts); err != nil { @@ -157,8 +157,8 @@ func (apierSv1 *APIerSv1) RemoveResourceProfile(ctx *context.Context, arg *utils // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) //handle caching for ResourceProfile if err := apierSv1.CallCache(utils.IfaceAsString(arg.APIOpts[utils.CacheOpt]), tnt, utils.CacheResourceProfiles, utils.ConcatenatedKey(tnt, arg.ID), utils.EmptyString, nil, nil, arg.APIOpts); err != nil { diff --git a/apier/v1/routes.go b/apier/v1/routes.go index b6da13d11..37b1f4d38 100644 --- a/apier/v1/routes.go +++ b/apier/v1/routes.go @@ -89,8 +89,8 @@ func (apierSv1 *APIerSv1) SetRouteProfile(ctx *context.Context, args *RouteWithA // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) //handle caching for SupplierProfile if err := apierSv1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), args.Tenant, utils.CacheRouteProfiles, args.TenantID(), utils.EmptyString, &args.FilterIDs, nil, args.APIOpts); err != nil { @@ -119,8 +119,8 @@ func (apierSv1 *APIerSv1) RemoveRouteProfile(ctx *context.Context, args *utils.T // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) //handle caching for SupplierProfile if err := apierSv1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), tnt, utils.CacheRouteProfiles, utils.ConcatenatedKey(tnt, args.ID), utils.EmptyString, nil, nil, args.APIOpts); err != nil { diff --git a/apier/v1/stats.go b/apier/v1/stats.go index 0d6d84f83..291c1e5b4 100644 --- a/apier/v1/stats.go +++ b/apier/v1/stats.go @@ -87,8 +87,8 @@ func (apierSv1 *APIerSv1) SetStatQueueProfile(ctx *context.Context, arg *engine. // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) //handle caching for StatQueueProfile if err = apierSv1.CallCache(utils.IfaceAsString(arg.APIOpts[utils.CacheOpt]), arg.Tenant, utils.CacheStatQueueProfiles, arg.TenantID(), utils.EmptyString, &arg.FilterIDs, nil, arg.APIOpts); err != nil { @@ -113,8 +113,8 @@ func (apierSv1 *APIerSv1) RemoveStatQueueProfile(ctx *context.Context, args *uti // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) //handle caching for StatQueueProfile if err := apierSv1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), tnt, utils.CacheStatQueueProfiles, utils.ConcatenatedKey(tnt, args.ID), utils.EmptyString, nil, nil, args.APIOpts); err != nil { diff --git a/apier/v1/thresholds.go b/apier/v1/thresholds.go index d15b3edd3..ecb678448 100644 --- a/apier/v1/thresholds.go +++ b/apier/v1/thresholds.go @@ -145,8 +145,8 @@ func (apierSv1 *APIerSv1) SetThresholdProfile(ctx *context.Context, args *engine // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) //handle caching for ThresholdProfile and Threshold if err := apierSv1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), args.Tenant, utils.CacheThresholdProfiles, args.TenantID(), utils.EmptyString, &args.FilterIDs, nil, args.APIOpts); err != nil { @@ -171,8 +171,8 @@ func (apierSv1 *APIerSv1) RemoveThresholdProfile(ctx *context.Context, args *uti // delay if needed before cache call if apierSv1.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", apierSv1.Config.GeneralCfg().CachingDelay)) + time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) } - time.Sleep(apierSv1.Config.GeneralCfg().CachingDelay) //handle caching for ThresholdProfile if err := apierSv1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), tnt, utils.CacheThresholdProfiles, utils.ConcatenatedKey(tnt, args.ID), utils.EmptyString, nil, nil, args.APIOpts); err != nil { diff --git a/apier/v2/apier.go b/apier/v2/apier.go index 4bf9000f1..ada2d9568 100644 --- a/apier/v2/apier.go +++ b/apier/v2/apier.go @@ -71,8 +71,8 @@ func (apiv2 *APIerSv2) LoadRatingProfile(ctx *context.Context, attrs *AttrLoadRa // delay if needed before cache reload if apiv2.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf("Delaying cache reload for %v", apiv2.Config.GeneralCfg().CachingDelay)) + time.Sleep(apiv2.Config.GeneralCfg().CachingDelay) } - time.Sleep(apiv2.Config.GeneralCfg().CachingDelay) if err = dbReader.ReloadCache(config.CgrConfig().GeneralCfg().DefaultCaching, true, make(map[string]any), apiv2.Config.GeneralCfg().DefaultTenant); err != nil { return utils.NewErrServerError(err) } @@ -165,8 +165,8 @@ func (apiv2 *APIerSv2) LoadTariffPlanFromFolder(ctx *context.Context, attrs *uti // delay if needed before cache reload if apiv2.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache reload for %v", apiv2.Config.GeneralCfg().CachingDelay)) + time.Sleep(apiv2.Config.GeneralCfg().CachingDelay) } - time.Sleep(apiv2.Config.GeneralCfg().CachingDelay) if err := loader.ReloadCache(caching, true, attrs.APIOpts, apiv2.Config.GeneralCfg().DefaultTimezone); err != nil { return utils.NewErrServerError(err) } diff --git a/apier/v2/attributes.go b/apier/v2/attributes.go index 47c2efd3c..389b8eac0 100644 --- a/apier/v2/attributes.go +++ b/apier/v2/attributes.go @@ -55,8 +55,8 @@ func (APIerSv2 *APIerSv2) SetAttributeProfile(ctx *context.Context, arg *Attribu // delay if needed before cache call if APIerSv2.Config.GeneralCfg().CachingDelay != 0 { utils.Logger.Info(fmt.Sprintf(" Delaying cache call for %v", APIerSv2.Config.GeneralCfg().CachingDelay)) + time.Sleep(APIerSv2.Config.GeneralCfg().CachingDelay) } - time.Sleep(APIerSv2.Config.GeneralCfg().CachingDelay) if err := APIerSv2.APIerSv1.CallCache(utils.IfaceAsString(arg.APIOpts[utils.CacheOpt]), alsPrf.Tenant, utils.CacheAttributeProfiles, alsPrf.TenantID(), utils.EmptyString, &alsPrf.FilterIDs, alsPrf.Contexts, arg.APIOpts); err != nil { return utils.APIErrorHandler(err) diff --git a/cmd/cgr-loader/cgr-loader.go b/cmd/cgr-loader/cgr-loader.go index 1437eecbb..85cec4ec1 100644 --- a/cmd/cgr-loader/cgr-loader.go +++ b/cmd/cgr-loader/cgr-loader.go @@ -417,8 +417,8 @@ func main() { // delay if needed before cache reload if *verbose && ldrCfg.GeneralCfg().CachingDelay != 0 { log.Printf("Delaying cache reload for %v", ldrCfg.GeneralCfg().CachingDelay) + time.Sleep(ldrCfg.GeneralCfg().CachingDelay) } - time.Sleep(ldrCfg.GeneralCfg().CachingDelay) // reload cache if err = tpReader.ReloadCache(ldrCfg.GeneralCfg().DefaultCaching, *verbose, map[string]any{ diff --git a/loaders/loader.go b/loaders/loader.go index 931baf2d4..f0fc64af7 100644 --- a/loaders/loader.go +++ b/loaders/loader.go @@ -560,8 +560,8 @@ func (ldr *Loader) storeLoadedData(loaderType string, // delay if needed before cache reload if ldr.cachingDelay != 0 { utils.Logger.Info(fmt.Sprintf("<%v> Delaying cache reload for %v", utils.LoaderS, ldr.cachingDelay)) + time.Sleep(ldr.cachingDelay) } - time.Sleep(ldr.cachingDelay) if len(ldr.cacheConns) != 0 { return engine.CallCache(ldr.connMgr, ldr.cacheConns, caching, cacheArgs, cacheIDs, nil, false, ldr.tenant) } @@ -811,8 +811,8 @@ func (ldr *Loader) removeLoadedData(loaderType string, lds map[string][]LoaderDa // delay if needed before cache reload if ldr.cachingDelay != 0 { utils.Logger.Info(fmt.Sprintf("<%v> Delaying cache reload for %v", utils.LoaderS, ldr.cachingDelay)) + time.Sleep(ldr.cachingDelay) } - time.Sleep(ldr.cachingDelay) if len(ldr.cacheConns) != 0 { return engine.CallCache(ldr.connMgr, ldr.cacheConns, caching, cacheArgs, cacheIDs, nil, false, ldr.tenant) }