mirror of
https://github.com/chubin/wttr.in
synced 2025-01-12 03:58:45 +00:00
srv.go: make prefetches in background
This commit is contained in:
parent
f488160294
commit
f31fff6f32
1 changed files with 3 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue