From d4bed308b15521abb2ed8bf2913a140191fa5a60 Mon Sep 17 00:00:00 2001 From: Derek Weitzel Date: Thu, 21 Apr 2022 14:34:47 -0500 Subject: [PATCH] Check for on-disk messages on startup Credit: Fabio Andrijauskas @biozit --- queue.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/queue.go b/queue.go index 5316dbb..5145c03 100644 --- a/queue.go +++ b/queue.go @@ -3,12 +3,13 @@ package main import ( "container/list" "errors" - "github.com/joncrlsn/dque" - log "github.com/sirupsen/logrus" - "github.com/spf13/viper" "path" "sync" "time" + + "github.com/joncrlsn/dque" + log "github.com/sirupsen/logrus" + "github.com/spf13/viper" ) type MessageStruct struct { @@ -57,6 +58,11 @@ func (cq *ConfirmationQueue) Init() *ConfirmationQueue { log.Errorln("Failed to turn on dque Turbo mode, the queue will be safer but much slower:", err) } + // Check if we have any messages in the queue + if cq.diskQueue.Size() > 0 { + cq.usingDisk = true + } + cq.emptyCond = sync.NewCond(&cq.mutex) // Start the metrics goroutine