Skip to content

Commit

Permalink
Suppress TIMEOUT messages (temporary)
Browse files Browse the repository at this point in the history
  • Loading branch information
chubin committed Jan 5, 2024
1 parent b1d4ddd commit 1228c73
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,13 @@ func (rp *RequestProcessor) processRequestFromCache(r *http.Request) *ResponseWi
}
}
if cacheEntry.InProgress {
log.Printf("TIMEOUT: %s\n", cacheDigest)
// log.Printf("TIMEOUT: %s\n", cacheDigest)
return &ResponseWithHeader{
InProgress: false,
Expires: time.Now().Add(time.Duration(randInt(1000, 1500)) * time.Second),
Body: []byte("This query is already being processed"),
StatusCode: 200,
}
}
if ok && !cacheEntry.InProgress && cacheEntry.Expires.After(time.Now()) {
rp.stats.Inc("cache1")
Expand All @@ -221,6 +227,9 @@ func (rp *RequestProcessor) processUncachedRequest(r *http.Request) (*ResponseWi
err error
)

// Indicate, that the request is being handled.
rp.lruCache.Add(cacheDigest, ResponseWithHeader{InProgress: true})

// Response was not found in cache.
// Starting real handling.
format := r.URL.Query().Get("format")
Expand Down

0 comments on commit 1228c73

Please sign in to comment.