-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
TASK: Cleanup projection catch-up trigger extensibility #5288
Merged
mhsdesign
merged 8 commits into
neos:9.0
from
mhsdesign:task/cleanup-ProjectionCatchUpTrigger-extensibility
Oct 22, 2024
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b0cb5be
TASK: Introduce `ContentRepository::catchupProjections`
mhsdesign 2a717fd
Remove ProjectionCatchUpTriggerInterface and implementations
bwaidelich ddac2c4
TASK: Fixup cherry-pick and adjust to use `CommandHandlingDependencies`
mhsdesign 0b6e2fa
TASK: Remove `PendingProjections` as we run the cr in sync mode
mhsdesign 9bbfce0
Merge remote-tracking branch 'origin/9.0' into task/cleanup-Projectio…
mhsdesign 36f18ab
Merge remote-tracking branch 'origin/9.0' into task/cleanup-Projectio…
mhsdesign d3119b8
TASK: Remove `CommandHandlingDependencies::publishEvents`
mhsdesign e5889e0
TASK: Adjust documentation of `markStale`
mhsdesign File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 0 additions & 133 deletions
133
Neos.ContentRepository.Core/Classes/CommandHandler/PendingProjections.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,6 @@ | |
final readonly class WorkspaceCommandHandler implements CommandHandlerInterface | ||
{ | ||
public function __construct( | ||
private EventPersister $eventPersister, | ||
private EventStoreInterface $eventStore, | ||
private EventNormalizer $eventNormalizer, | ||
) { | ||
|
@@ -202,6 +201,7 @@ private function handlePublishWorkspace( | |
$baseWorkspace = $this->requireBaseWorkspace($workspace, $commandHandlingDependencies); | ||
|
||
$this->publishContentStream( | ||
$commandHandlingDependencies, | ||
$workspace->currentContentStreamId, | ||
$baseWorkspace->workspaceName, | ||
$baseWorkspace->currentContentStreamId | ||
|
@@ -238,10 +238,11 @@ private function handlePublishWorkspace( | |
* @throws \Exception | ||
*/ | ||
private function publishContentStream( | ||
CommandHandlingDependencies $commandHandlingDependencies, | ||
ContentStreamId $contentStreamId, | ||
WorkspaceName $baseWorkspaceName, | ||
ContentStreamId $baseContentStreamId, | ||
): ?CommandResult { | ||
): void { | ||
$baseWorkspaceContentStreamName = ContentStreamEventStreamName::fromContentStreamId( | ||
$baseContentStreamId | ||
); | ||
|
@@ -286,10 +287,10 @@ private function publishContentStream( | |
} | ||
|
||
if (count($events) === 0) { | ||
return null; | ||
return; | ||
} | ||
try { | ||
return $this->eventPersister->publishEvents( | ||
$commandHandlingDependencies->publishEvents( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so this seems to be the single use of this weird API, why don't we keep the EventPersister here? |
||
new EventsToPublish( | ||
$baseWorkspaceContentStreamName->getEventStreamName(), | ||
Events::fromArray($events), | ||
|
@@ -501,6 +502,7 @@ function () use ($matchingCommands, $commandHandlingDependencies, $baseWorkspace | |
|
||
// 5) take EVENTS(MATCHING) and apply them to base WS. | ||
$this->publishContentStream( | ||
$commandHandlingDependencies, | ||
$command->contentStreamIdForMatchingPart, | ||
$baseWorkspace->workspaceName, | ||
$baseWorkspace->currentContentStreamId | ||
|
20 changes: 0 additions & 20 deletions
20
Neos.ContentRepository.Core/Classes/Projection/ProjectionCatchUpTriggerInterface.php
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the weirdest API, why would we have this here?
CommandHandlingDependencies::publishEvents
makes no sense to me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the problem is that for publishing events we need a catchup afterwards and the catchup hook extensibility require the content repository to be build.
The
CommandHandlingDependencies
are a purely internal thing and thehandle()
method on it already is a code smell due to the workspace command handler "doing to much" besides just publishing events for one command as we issue sub commands in the middle of handling another command.For publishing an event stream, we need low level access to publish all events which was previously done via
$this->eventPersister->publishEvents($events)
.This leveraged the odd dependency flow of refetching the content repository from the Neos registry (see comment above) but now we need to pass the content repository for the said reasons explicitly.
Instead of exposing the content repository from
$commandHandlingDependencies
and using it like$this->eventPersister->publishEvents($events, $commandHandlingDependencies->contentRepository)
i propose to keep the contentRepository instance private and introduce the new method:$commandHandlingDependencies->publishEvents($events)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather expose the CR here instead of adding this method, but maybe an abstraction around projection catchup is not bad, I do like the current api better than what happens in this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we discussed having a factory like so, but the catchup logic is still placed ON the content repository and we would have to move the codeblock to the event persister ...
Also introducing a read site content repository or just passing the content repository read model to the catchup hooks would certainly be promising as it would prevent recursive handling via
handle
but nothing for now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha @kitsunet with #5301 on the rise i guess i can revert d3119b8 as well have so much logic on the poor object that an additional method
persistEvents
wouldn't hurt :DI just experimented with returning the events instead of handling them in between, which is much cleaner imo and would allow us to actually get rid of that thing :D https://neos-project.slack.com/archives/C0L41E268/p1729546247272549
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still like it better this way 😆