-
Notifications
You must be signed in to change notification settings - Fork 174
do not load all events to check for conflicts #403
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
do not load all events to check for conflicts #403
Conversation
28149aa to
bc5b13e
Compare
AlessandroMinoccheri
left a comment
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.
Is it possible to add a test for this behavior?
|
@AlessandroMinoccheri what would you like to test exactly, since the functionality is exactly the same as before and already tested in https://github.com/broadway/broadway/blob/master/test/Broadway/EventStore/ConflictResolvingEventStoreTest.php? |
|
I would like to know if it's possible to explicit well this behavior. I was mostly wondering if it was possible or not @marcosh |
@AlessandroMinoccheri the behaviour should not be changing, that's why I think already present tests should be enough. This is basically just a refactoring |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
hey, anyone there? is broadway officialy a dead project? |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
What do you think @othillo of this PR? For me it's ok. |
| $events = iterator_to_array($uncommittedEvents); | ||
| /** @var DomainMessage $firstEvent */ | ||
| $firstEvent = current($events); | ||
| $playhead = $firstEvent->getPlayhead(); |
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 breaks when there are no uncommitted 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.
if $uncommittedEvents is empty, I'd find it odd to receive a DeplicatePlayheadException.
Anyway, I added a check to skip every work if the DomainEventStream is empty
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 don't mean to throw a DuplicatePlayheadException, I'm just saying that if $uncommittedEvents is empty PHP will error because the $firstEvent->getPlayhead() method does not exist.
Maybe we should add a test for appending zero uncommitted events to be sure.
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 meant that this private method is called only in case of a DuplicatePlayheadException. And in that case I would find it odd to receive an empty $uncommittedEvents.
Anyway, I added the test to ensure everything works as expected.
Moreover, I added a $id = (string)$id to throw a Throwable even in case $uncommittedEvents is empty, to avoid creating a breaking change on the API
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.
@othillo is there anything I could do on this to get this merged?
e2fa74d to
f526328
Compare
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
wjzijderveld
left a comment
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'll fix the coding-standards issue in master
|
Thanks @marcosh ! |
currently all events are loaded to check if there are concurrency conflicts.
It should be enough to load events from the initial playhead of the uncommitted events.
This could save some computations in case there are a bit of events before the conflicting playhead