Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Replace CatchUpHooks with ContentRepositoryHooks #4995

Draft
wants to merge 12 commits into
base: feature/4746-rework-catchup-mechanism
Choose a base branch
from

Conversation

bwaidelich
Copy link
Member

@bwaidelich bwaidelich commented Apr 18, 2024

Resolves: #4992

WIP because

@bwaidelich bwaidelich changed the title WIP: Rework CatchUpHooks WIP: Replace CatchUpHooks with ContentRepositoryHooks Apr 19, 2024
$lock->release();
}

/**
* NOTE: This will NOT trigger hooks!
*
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to CatchUpService?

foreach ($this->projections as $projection) {
if (!$projection->getCheckpoint()->equals($expectedCheckpoint)) {
//throw new \RuntimeException(sprintf('Projection %s is at checkpoint %d, but was expected to be at %d', $projection::class, $projection->getCheckpoint()->value, $expectedCheckpoint->value), 1714062281);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed with @skurfuerst :
No reason to "stop the world" here, but we should add some result object that contains the projections that were updated/skipped such that we can inform the user immediately

$event = $this->eventNormalizer->denormalize($eventEnvelope->event);
$hooks->dispatchBeforeEvent($event, $eventEnvelope);
foreach ($projectionsToUpdate as $projection) {
$projection->apply($event, $eventEnvelope);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: try/catch -> collect exceptions and throw one combined exception after releasing the lock in line 85

$contentRepository->catchUpProjections();

$hooks->dispatchBeforeCatchUp();
foreach ($this->eventStore->load($eventsToPublish->streamName)->withMinimumSequenceNumber($expectedCheckpoint->next()) as $eventEnvelope) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might read more events than were published..
I think we also need to specify the max sequence number!?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think it's correct this way. But it means that a newly published event might haven been applied in a separate process already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant