From f31fff6f32b1b5a0737f114bbb887750b1ad5180 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Mon, 1 Jun 2020 14:18:03 +0200 Subject: [PATCH] srv.go: make prefetches in background --- cmd/peakHandling.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/peakHandling.go b/cmd/peakHandling.go index 870f7e7..eb98191 100644 --- a/cmd/peakHandling.go +++ b/cmd/peakHandling.go @@ -61,8 +61,9 @@ func prefetchPeakRequests(peakRequestMap *sync.Map) { } sleepBetweenRequests := time.Duration(prefetchInterval*1000/peakRequestLen) * time.Millisecond peakRequestMap.Range(func(key interface{}, value interface{}) bool { - r := value.(http.Request) - prefetchRequest(&r) + go func(r http.Request) { + prefetchRequest(&r) + }(value.(http.Request)) peakRequestMap.Delete(key) time.Sleep(sleepBetweenRequests) return true