From 1228c73a594ebaa1b6db5e488d2ac624b138e276 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Fri, 5 Jan 2024 21:53:54 +0100 Subject: [PATCH] Suppress TIMEOUT messages (temporary) --- internal/processor/processor.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/processor/processor.go b/internal/processor/processor.go index 5c254ef..44ff69e 100644 --- a/internal/processor/processor.go +++ b/internal/processor/processor.go @@ -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") @@ -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")