Skip to content

Commit

Permalink
Merge pull request #462 from patchlevel/sync-projectionist-throw-by-e…
Browse files Browse the repository at this point in the history
…rror

add throw by error flag in sync projectionist wrapper
  • Loading branch information
DavidBadura authored Jan 10, 2024
2 parents b60f718 + 05ede53 commit 65b5875
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/Projection/Projectionist/DefaultProjectionist.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ public function boot(
$e->getMessage(),
));

$projection->error(ProjectionError::fromThrowable($e));
$projection->disallowRetry();
$this->projectionStore->save($projection);

if ($throwByError) {
throw new ProjectionistError(
$projector::class,
$projection->id(),
$e,
);
}

$projection->error(ProjectionError::fromThrowable($e));
$projection->disallowRetry();
$this->projectionStore->save($projection);
}
}

Expand Down Expand Up @@ -469,6 +469,10 @@ private function handleMessage(Message $message, Projection $projection, bool $t
),
);

$projection->error(ProjectionError::fromThrowable($e));
$projection->incrementRetry();
$this->projectionStore->save($projection);

if ($throwByError) {
throw new ProjectionistError(
$projector::class,
Expand All @@ -477,10 +481,6 @@ private function handleMessage(Message $message, Projection $projection, bool $t
);
}

$projection->error(ProjectionError::fromThrowable($e));
$projection->incrementRetry();
$this->projectionStore->save($projection);

return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function __construct(
private readonly EventBus $parentEventBus,
private readonly Projectionist $projectionist,
private readonly LockFactory $lockFactory,
private readonly bool $throwByError = true,
) {
}

Expand All @@ -29,7 +30,7 @@ public function dispatch(Message ...$messages): void
}

try {
$this->projectionist->run();
$this->projectionist->run(throwByError: $this->throwByError);
} finally {
$lock->release();
}
Expand Down

0 comments on commit 65b5875

Please sign in to comment.