Skip to content

Commit

Permalink
[pr feedback] gosqs: ReceiveMessage() exit earlier if queue not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien cante committed Sep 26, 2019
1 parent f7154e4 commit 8a82883
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions app/gosqs/gosqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,13 @@ func ReceiveMessage(w http.ResponseWriter, req *http.Request) {
for loops > 0 {
app.SyncQueues.RLock()
_, queueFound := app.SyncQueues.Queues[queueName]
var messageFound bool
if queueFound {
messageFound = len(app.SyncQueues.Queues[queueName].Messages)-numberOfHiddenMessagesInQueue(*app.SyncQueues.Queues[queueName]) != 0
}
app.SyncQueues.RUnlock()
if !queueFound {
app.SyncQueues.RUnlock()
createErrorResponse(w, req, "QueueNotFound")
return
}
messageFound := len(app.SyncQueues.Queues[queueName].Messages)-numberOfHiddenMessagesInQueue(*app.SyncQueues.Queues[queueName]) != 0
app.SyncQueues.RUnlock()
if !messageFound {
time.Sleep(100 * time.Millisecond)
loops--
Expand Down

0 comments on commit 8a82883

Please sign in to comment.