Skip to content

Commit

Permalink
refactor(batch): Reset timer when there are no items in the batch
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Oct 23, 2023
1 parent 6ff8770 commit a4083b1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/processor/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,12 @@ func (bvp *BatchItemProcessor[T]) batchBuilder(ctx context.Context) {
bvp.batches <- batchCopy
bvp.batch = bvp.batch[:0]
bvp.batchReady <- true
} else {
// Reset the timer if there are no items in the batch.
// If there are items in the batch, one of the workers will reset the timer.
bvp.timer.Reset(bvp.o.BatchTimeout)
}

bvp.timer.Reset(bvp.o.BatchTimeout)

bvp.batchMutex.Unlock()
}
}
Expand Down

0 comments on commit a4083b1

Please sign in to comment.