Comments (1)
Hi @beachwalker ,
I know that this issue is quite old, but I would like to contribute.
The reason for which the Event class is mutable is related to the need of assigning the right version to the event itself, when the event is appended to the event stream. This is done right after the optimistic concurrency check in the EventStore
class, see here at line 62.
Two subjects somewhat related to this are the issue #7 and the issue #31 that I recently opened in order to better understand what is the semantic of the Version
property.
If my interpretation of the Version
property is fine (see #31 for details), we could submit a pull request in order to fix both this issue and #7 . This is the top level plan:
- fix the issue #7 so that each time an event is applied to the aggregate state the
Version
property is incremented by 1 (it must be clear how to initialize the counter of the aggregate version. I guess that in Greg's view the aggregate version should be zero after applying the first event. Anyway, it's just a matter of preference, we should only agree on a convention). - change the
Event
base class so that theVersion
property becomes read only. We could add a protected constructor requesting the value forVersion
as its sole parameter - change the code which raises an event inside the aggregate, so that the value for
Event.Version
is passed inside the event constructor asthis.Version + 1
(the current aggregate version plus one). - the optimistic concurrency check in the
EventStore
class will stay the same, the only change is removing the code at line 62 in theEventStore
class (because theEvent.Version
property won't be writable anymore).
I'm quite confident that assigning the Version to an event in advance (before performing the optimistic concurrency check) won't break anything on the correctness side: if there are concurrency issues the events won't be appended to the event stream so the Version assigned to them is not relevant. Otherwise, in case of a successful optimistic concurrency check, the event Version assigned this way is exactly the same as the one assigned by the currently existing code (because the command is performed against the most recent aggregate version available and, when the events are saved, the aggregate version in the event store is not changed because the optimistic concurrency check was successful).
from m-r.
Related Issues (20)
- EventDescriptor purpose HOT 4
- Add LICENSE to repository HOT 2
- About FakeBus sample implementation and contracts for the registration HOT 13
- How to implement business rules? HOT 10
- Why do commands include the entity id when creating entities? HOT 34
- How to implement bulk processing? HOT 6
- Deactivate action should be POST
- Extraneous properties (and even class)? HOT 2
- Should configuration settings be eventsourced? HOT 1
- Use ReflectionMagic and get rid of InfrastructureCrap.DontBotherReadingItsNotImportant.cs HOT 2
- aggregate id and aggregate root HOT 16
- CQRS and CRUD misconception HOT 21
- Remove bus from projections HOT 1
- Test
- What is the semantic of the Version property in the Event class ?
- Regarding the class naming convention HOT 3
- Race between event handlers and read model facade after commands HOT 1
- AggregateRoot version never updated HOT 9
- Why use DelegateAdjuster? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from m-r.