Added concurent requests for ees

This commit is contained in:
Trial97
2021-07-21 17:07:57 +03:00
committed by Dan Christian Bogos
parent f1796317a0
commit 24b09329be
20 changed files with 215 additions and 97 deletions

View File

@@ -36,6 +36,7 @@ func NewHTTPjsonMapEE(cgrCfg *config.CGRConfig, cfgIdx int, filterS *engine.Filt
cfgIdx: cfgIdx,
filterS: filterS,
dc: dc,
reqs: newConcReq(cgrCfg.EEsCfg().Exporters[cfgIdx].ConcurrentRequests),
}
pstrJSON.pstr, err = engine.NewHTTPPoster(cgrCfg.GeneralCfg().ReplyTimeout,
@@ -53,6 +54,7 @@ type HTTPjsonMapEE struct {
filterS *engine.FilterS
pstr *engine.HTTPPoster
dc *utils.SafeMapStorage
reqs *concReq
}
// ID returns the identificator of this exporter
@@ -65,9 +67,11 @@ func (httpEE *HTTPjsonMapEE) OnEvicted(string, interface{}) {}
// ExportEvent implements EventExporter
func (httpEE *HTTPjsonMapEE) ExportEvent(cgrEv *utils.CGREvent) (err error) {
httpEE.reqs.get()
defer func() {
updateEEMetrics(httpEE.dc, cgrEv.ID, cgrEv.Event, err != nil, utils.FirstNonEmpty(httpEE.cgrCfg.EEsCfg().Exporters[httpEE.cfgIdx].Timezone,
httpEE.cgrCfg.GeneralCfg().DefaultTimezone))
httpEE.reqs.done()
}()
httpEE.dc.Lock()
httpEE.dc.MapStorage[utils.NumberOfEvents] = httpEE.dc.MapStorage[utils.NumberOfEvents].(int64) + 1