Skip to content

Commit

Permalink
Consider to flush buffer after a record has been processed (#62)
Browse files Browse the repository at this point in the history
* Consider to flush buffer after a record has been processed

* Fix syntax
  • Loading branch information
holtkamp authored and maxbanton committed May 21, 2019
1 parent fc9b602 commit 4ee243d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Handler/CloudWatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,14 @@ protected function write(array $record)
$records = $this->formatRecords($record);

foreach ($records as $record) {
if ($this->currentDataAmount + $this->getMessageSize($record) >= $this->dataAmountLimit ||
count($this->buffer) >= $this->batchSize
) {
if ($this->currentDataAmount + $this->getMessageSize($record) >= $this->dataAmountLimit) {
$this->flushBuffer();
}

$this->addToBuffer($record);

if (count($this->buffer) >= $this->batchSize) {
$this->flushBuffer();
$this->addToBuffer($record);
} else {
$this->addToBuffer($record);
}
}
}
Expand Down

0 comments on commit 4ee243d

Please sign in to comment.