Skip to content

Commit

Permalink
[chore] persistent queue small nit in variable declaration (#9120)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Dec 15, 2023
1 parent 6b12cc3 commit 12895ea
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions exporter/exporterhelper/internal/persistent_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,16 @@ func (pq *persistentQueue[T]) initPersistentContiguousStorage(ctx context.Contex
// The call blocks until there is an item available or the queue is stopped.
// The function returns true when an item is consumed or false if the queue is stopped.
func (pq *persistentQueue[T]) Consume(consumeFunc func(context.Context, T) error) bool {
var (
req T
onProcessingFinished func(error)
consumed bool
)

for {
select {
case <-pq.stopChan:
return false
case <-pq.putChan:
req, onProcessingFinished, consumed = pq.getNextItem(context.Background())
}

if consumed {
onProcessingFinished(consumeFunc(context.Background(), req))
return true
req, onProcessingFinished, consumed := pq.getNextItem(context.Background())
if consumed {
onProcessingFinished(consumeFunc(context.Background(), req))
return true
}
}
}
}
Expand Down

0 comments on commit 12895ea

Please sign in to comment.