From 24763c95d26535b093476b1c6b21dcbceb1ff55c Mon Sep 17 00:00:00 2001 From: Nick White Date: Thu, 22 Aug 2019 10:23:56 +0100 Subject: Improve timing of queue checks Now each queue is checked every 3 minutes, though the channel for each queue check request won't be rechecked until any previous job is completed. --- pipelinepreprocess/main.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pipelinepreprocess/main.go b/pipelinepreprocess/main.go index 029ac76..f53aac0 100644 --- a/pipelinepreprocess/main.go +++ b/pipelinepreprocess/main.go @@ -25,7 +25,7 @@ func (w NullWriter) Write(p []byte) (n int, err error) { return len(p), nil } -const PauseBetweenChecks = 60 * time.Second +const PauseBetweenChecks = 3 * time.Minute type Clouder interface { Init() error @@ -293,38 +293,34 @@ func main() { select { case <- checkPreQueue: msg, err := conn.CheckPreQueue() + checkPreQueue = time.After(PauseBetweenChecks) if err != nil { log.Println("Error checking preprocess queue", err) - checkPreQueue = time.After(PauseBetweenChecks) continue } if msg.Handle == "" { verboselog.Println("No message received on preprocess queue, sleeping") - checkPreQueue = time.After(PauseBetweenChecks) continue } err = preProcBook(msg, conn) if err != nil { log.Println("Error during preprocess", err) } - checkPreQueue = time.After(0) case <- checkOCRQueue: msg, err := conn.CheckOCRQueue() + checkOCRQueue = time.After(PauseBetweenChecks) if err != nil { log.Println("Error checking OCR queue", err) - checkOCRQueue = time.After(PauseBetweenChecks) continue } if msg.Handle == "" { verboselog.Println("No message received on OCR queue, sleeping") - checkOCRQueue = time.After(PauseBetweenChecks) continue } err = ocrBook(msg, conn) if err != nil { log.Println("Error during OCR process", err) } - checkOCRQueue = time.After(0) } } } -- cgit v1.2.1-24-ge1ad