From 12895eaeb9d794b63e2d5bfa7e7a6cfc59492556 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Fri, 15 Dec 2023 11:57:42 -0800 Subject: [PATCH] [chore] persistent queue small nit in variable declaration (#9120) Signed-off-by: Bogdan Drutu --- .../exporterhelper/internal/persistent_queue.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/exporter/exporterhelper/internal/persistent_queue.go b/exporter/exporterhelper/internal/persistent_queue.go index c635f7fa052..e766d703e03 100644 --- a/exporter/exporterhelper/internal/persistent_queue.go +++ b/exporter/exporterhelper/internal/persistent_queue.go @@ -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 + } } } }