Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/PdoEventSourcing/src/Prooph/GapDetection.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ public function getDefinition(): Definition

public function build(): ProophGapDetection
{
return new ProophGapDetection($this->retryConfig, $this->detectionWindow?->build());
return new ProophGapDetection($this->retryDelaysInMicroseconds(), $this->detectionWindow?->build());
}

private function retryDelaysInMicroseconds(): ?array
{
if ($this->retryConfig === null) {
return null;
}

return array_map(
static fn (int $delayInMilliseconds): int => $delayInMilliseconds * 1000,
$this->retryConfig,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ public function test_detecting_gaps_with_detection_window(): void
);
}

public function test_retry_delays_are_waited_in_milliseconds_before_skipping_gap(): void
{
$ecotone = $this->bootstrapEcotoneWithGapDetection(new GapDetection([0, 300], new DateInterval('PT60S')));

$startedAt = microtime(true);
$ecotone->sendCommand(new CloseTicket('124'));
$elapsedMilliseconds = (microtime(true) - $startedAt) * 1000;

self::assertGreaterThanOrEqual(300, $elapsedMilliseconds);
}

public function test_running_projection_without_gap_detection(): void
{
$ecotone = $this->bootstrapEcotoneWithGapDetection(null);
Expand Down
Loading