Skip to content

Commit b58ab06

Browse files
authored
Merge pull request #261 from zluiten/feature-gap-detector-interface
Apply GapDetector interface to the PdoEventStoreReadModelProjector
2 parents 3472ada + 4876f20 commit b58ab06

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/Projection/PdoEventStoreReadModelProjector.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ final class PdoEventStoreReadModelProjector implements MetadataAwareReadModelPro
153153
private $updateLockThreshold;
154154

155155
/**
156-
* @var GapDetection|null
156+
* @var GapDetector|null
157157
*/
158-
private $gapDetection;
158+
private $gapDetector;
159159

160160
/**
161161
* @var array|null
@@ -190,7 +190,7 @@ public function __construct(
190190
?int $loadCount = null,
191191
bool $triggerPcntlSignalDispatch = false,
192192
int $updateLockThreshold = 0,
193-
?GapDetection $gapDetection = null
193+
?GapDetector $gapDetection = null
194194
) {
195195
if ($triggerPcntlSignalDispatch && ! \extension_loaded('pcntl')) {
196196
throw Exception\ExtensionNotLoadedException::withName('pcntl');
@@ -209,7 +209,7 @@ public function __construct(
209209
$this->status = ProjectionStatus::IDLE();
210210
$this->triggerPcntlSignalDispatch = $triggerPcntlSignalDispatch;
211211
$this->updateLockThreshold = $updateLockThreshold;
212-
$this->gapDetection = $gapDetection;
212+
$this->gapDetector = $gapDetection;
213213
$this->vendor = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME);
214214
while ($eventStore instanceof EventStoreDecorator) {
215215
/** @var EventStoreDecorator $eventStore */
@@ -533,14 +533,14 @@ public function run(bool $keepRunning = true): void
533533
$gapDetected = ! $this->handleStreamWithHandlers($streamEvents);
534534
}
535535

536-
if ($gapDetected && $this->gapDetection) {
537-
$sleep = $this->gapDetection->getSleepForNextRetry();
536+
if ($gapDetected && $this->gapDetector) {
537+
$sleep = $this->gapDetector->getSleepForNextRetry();
538538

539539
\usleep($sleep);
540-
$this->gapDetection->trackRetry();
540+
$this->gapDetector->trackRetry();
541541
$this->persist();
542542
} else {
543-
$this->gapDetection && $this->gapDetection->resetRetries();
543+
$this->gapDetector && $this->gapDetector->resetRetries();
544544

545545
if (0 === $this->eventCounter) {
546546
\usleep($this->sleep);
@@ -632,9 +632,9 @@ private function handleStreamWithSingleHandler(MergedStreamIterator $events): bo
632632

633633
$this->currentStreamName = $events->streamName();
634634

635-
if ($this->gapDetection
636-
&& $this->gapDetection->isGapInStreamPosition((int) $this->streamPositions[$this->currentStreamName], (int) $key)
637-
&& $this->gapDetection->shouldRetryToFillGap(new \DateTimeImmutable('now', new DateTimeZone('UTC')), $event)
635+
if ($this->gapDetector
636+
&& $this->gapDetector->isGapInStreamPosition((int) $this->streamPositions[$this->currentStreamName], (int) $key)
637+
&& $this->gapDetector->shouldRetryToFillGap(new \DateTimeImmutable('now', new DateTimeZone('UTC')), $event)
638638
) {
639639
return false;
640640
}
@@ -668,9 +668,9 @@ private function handleStreamWithHandlers(MergedStreamIterator $events): bool
668668

669669
$this->currentStreamName = $events->streamName();
670670

671-
if ($this->gapDetection
672-
&& $this->gapDetection->isGapInStreamPosition((int) $this->streamPositions[$this->currentStreamName], (int) $key)
673-
&& $this->gapDetection->shouldRetryToFillGap(new \DateTimeImmutable('now', new DateTimeZone('UTC')), $event)
671+
if ($this->gapDetector
672+
&& $this->gapDetector->isGapInStreamPosition((int) $this->streamPositions[$this->currentStreamName], (int) $key)
673+
&& $this->gapDetector->shouldRetryToFillGap(new \DateTimeImmutable('now', new DateTimeZone('UTC')), $event)
674674
) {
675675
return false;
676676
}

0 commit comments

Comments
 (0)