From 9d34293603a4bc1690a07c0ee6595bc79c5724b7 Mon Sep 17 00:00:00 2001 From: DanB Date: Sat, 31 Oct 2020 20:41:33 +0100 Subject: [PATCH] Concurrent requests configured also via shared variable --- cmd/cgr-engine/cgr-engine.go | 10 +++++++++- utils/concureqs.go | 2 +- utils/consts.go | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go index 1c6feb449..7bf039717 100644 --- a/cmd/cgr-engine/cgr-engine.go +++ b/cmd/cgr-engine/cgr-engine.go @@ -450,7 +450,15 @@ func main() { } utils.Logger.SetLogLevel(lgLevel) // init the concurrentRequests - utils.ConReqs = utils.NewConReqs(cfg.GeneralCfg().ConcurrentRequests, cfg.GeneralCfg().ConcurrentStrategy) + cncReqsLimit := cfg.GeneralCfg().ConcurrentRequests + if utils.ConcurrentReqsLimit != 0 { // used as shared variable + cncReqsLimit = utils.ConcurrentReqsLimit + } + cncReqsStrategy := cfg.GeneralCfg().ConcurrentStrategy + if utils.ConcurrentReqsStrategy != "" { + cncReqsStrategy = utils.ConcurrentReqsStrategy + } + utils.ConReqs = utils.NewConReqs(cncReqsLimit, cncReqsStrategy) utils.Logger.Info(fmt.Sprintf(" starting version <%s><%s>", vers, goVers)) cfg.LazySanityCheck() diff --git a/utils/concureqs.go b/utils/concureqs.go index 2a53372af..78fa05e5a 100644 --- a/utils/concureqs.go +++ b/utils/concureqs.go @@ -46,7 +46,7 @@ func NewConReqs(reqs int, strategy string) *ConcReqs { // IsLimited returns true if the limit is not 0 func (cR *ConcReqs) IsLimited() bool { - return ConReqs.limit != 0 + return cR.limit != 0 } // Allocate will reserve a channel for the API call diff --git a/utils/consts.go b/utils/consts.go index fdfa0c90c..faa5f295d 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -871,6 +871,8 @@ const ( ProcessRuns = "ProcessRuns" HashtagSep = "#" MetaRounding = "*rounding" + ConcurrentReqsLimit = 0 + ConcurrentReqsStrategy = "" ) // Migrator Action