-
-
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: Add onAfterHandle to CommandHookInterface #5468
base: 9.0
Are you sure you want to change the base?
TASK: Add onAfterHandle to CommandHookInterface #5468
Conversation
@@ -130,6 +131,7 @@ public function handle(CommandInterface $command): void | |||
throw $concurrencyException; | |||
} | |||
} | |||
$this->commandHook->onAfterHandle($command); |
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 line must be executed after belows if ($fullCatchUpResult->hadErrors()) {
as other-wise the cr is not up to date. Though im not sure if the hook should be run in the finally
block if there was an exception like $concurrencyException
... probably not. So we need to change the finally
block to be catch (\Throwable)
and and run the onAfterHandle
only if that was not the case.
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.
Moved the hook to the end of the finally block. In case the $fullCatchUpResult->hadErrors()
this is never reached because an error is thrown before. That way the behavior is equal regardless wether Events or a Generator are beeing committed.
794ba0e
to
ba2e393
Compare
This allows to return additional Commands after the just executed ones were projected. Example. Add automatic translations to a freshly created node variant.
ba2e393
to
048d5c2
Compare
Note: After this is merged the existing use cases should be updated as well and return empty commands onHandle. |
6882723
to
58e4166
Compare
…e->onAfterHandle()
58e4166
to
11dc3c4
Compare
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.
Events is not API! And contains the Decorated Event which is not api either and that makes sense as this is write only ... also the time stamps etc might be cool to have
The catchup hook or projections get:
onBeforeEvent(EventInterface $eventInstance, EventEnvelope $eventEnvelope)
But we dont have the EventEnvelope
at hand at the moment as this is only a thing when fetching the events again...
as we also talked about performance maybe we dont want to have each hook load the events now ... but we could hand over them the event stream to look into it ... thought the stream is wayyy to low level and requires the internal EventNormaliser too ...
Renaming the internal Events
to EventsToWrite
and then introduce a Events
thing with only EventInterface
might be a way? For accessing its eventMetaData one would still have to use a catchup hook ...
Otherwise i really like the idea and added some cool tests 🧪 :D
as we need a new `Events` API class for `onAfterHandle` in the command hooks
We dont want to use the `DecoratedEvents` as they are only needed for the write site and internal.
This allows to return additional commands after the just executed one was handled. The onAfterHandle method gets the processed command plus all resulting events.
Example use cases: Add automatic translations to a freshly created node variant. Or create translations in a review workspace when changes are published to the live workspace.
Resolves: #5469
Upgrade instructions
Review instructions
Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions