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

Make UncommittedHistory remember only successfully applied events #1439

Open
wants to merge 39 commits into
base: master
Choose a base branch
from

Conversation

yevhenii-nadtochii
Copy link
Contributor

@yevhenii-nadtochii yevhenii-nadtochii commented Jan 4, 2022

This PR addresses #1313.

The issue appears when multiple messages are dispatched from Inbox. Under the hood, those messages are processed as a batch, which triggers Aggregate to be cached for their processing. Going this way, Aggregate puts applied events into UncommittedHistory to send them to a storage lately.

Now, events emitted by a single command are put into the history only if they all were applied successfully. This behavior matches to the one of non-cached Aggregate.

Additionally, initialization of Delivery was dropped out of ServerEnvironment.reset(). Delivery is lazily initialized the same way in its getter ServerEnvironment.delivery().

The library version is bumped to 2.0.0-SNAPSHOT.92.

@yevhenii-nadtochii yevhenii-nadtochii self-assigned this Jan 4, 2022
@codecov
Copy link

codecov bot commented Jan 4, 2022

Codecov Report

Merging #1439 (8461f99) into master (c6b7be4) will increase coverage by 0.03%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master    #1439      +/-   ##
============================================
+ Coverage     91.41%   91.45%   +0.03%     
+ Complexity     4946     4944       -2     
============================================
  Files           622      622              
  Lines         15216    15196      -20     
  Branches        891      891              
============================================
- Hits          13910    13897      -13     
+ Misses         1001      994       -7     
  Partials        305      305              

@yevhenii-nadtochii yevhenii-nadtochii changed the title Fix uncommitted list Make UncommittedHistory contain only successfully applied events Jan 11, 2022
@yevhenii-nadtochii yevhenii-nadtochii marked this pull request as ready for review January 11, 2022 16:12
@yevhenii-nadtochii yevhenii-nadtochii changed the title Make UncommittedHistory contain only successfully applied events Make Aggregate put only successfully applied events to UncommittedHistory Jan 11, 2022
@yevhenii-nadtochii yevhenii-nadtochii changed the title Make Aggregate put only successfully applied events to UncommittedHistory Make UncommittedHistory remember only successfully applied events Jan 13, 2022
Copy link
Contributor

@armiol armiol left a comment

Choose a reason for hiding this comment

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

@yevhenii-nadtochii mostly LGTM. Please see my comments.

Also, please file an issue telling we might need a mechanism that would determine, whether the command dispatching is a "transactional" operation (meaning "all or nothing"). And describing the current state of things.

@yevhenii-nadtochii yevhenii-nadtochii marked this pull request as draft January 14, 2022 15:59
@yevhenii-nadtochii yevhenii-nadtochii marked this pull request as ready for review January 18, 2022 16:57
@alexander-yevsyukov alexander-yevsyukov added this to the M1 milestone Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add events to the list of uncommitted in Aggregate only if they are successfully applied to the entity
3 participants