jwindridge / event-sourcing-kit Goto Github PK
View Code? Open in Web Editor NEWKit of common elements used for building applications using an event-sourcing pattern
License: MIT License
Kit of common elements used for building applications using an event-sourcing pattern
License: MIT License
Currently, repositories load all aggregate instances by replaying the full event history from version 0.
For small deployments / low-throughput systems this is fine (initially), however repository latency will increase linearly with application activity, since the repository will have to traverse more of the event history with each operation.
Adding an optional argument to the repository to allow it to intermittently save serialized aggregate states & only load events that have occurred since that point allows for faster load times.
Currently all attempts to apply a command to an aggregate with an incorrect version raise an error - need to add an optional function to an aggregate root that can determine whether the Repository can tolerate the version mismatch, or whether the command should be rejected.
Should receive the following arguments:
currentState
: Current state of the aggregate once all events from the store have been appliedexpectedState
: State of the aggregate at the version expected by the commandsavedEvents
: Array of the events that have been saved to the aggregate between the expected & current versionsnewEvents
: Array of the domain events that caused the AppendOnlyStoreConcurrencyErrorFunction signature:
interface IConcurrentModificationHandler<T> {
({
currentState: IAggregateState<T>,
expectedState: IAggregateState<T>,
newEvents: IDomainEvent[],
savedEvents: IAggregateEvent[]
}): boolean
}
The function should return true
iff all of the events rejected from the event store can be tolerated by the aggregate & should be appended onto the end of the event stream for this aggregate.
This can then be utilised within a try/catch block in a Repository in order to determine whether a "genuine" ConcurrencyError needs to be raised or whether it can be swallowed silently.
By using the @injectable
& @inject
decorators present within the inversify framework, the storage backing aggregate repositories, messaging, etc. can be implemented in this library while leaving wiring up of dependencies to consumers via appropriate set up of Inversify container instances at application startup.
File handles are left open in the _ensureExists
function call, by virtue of a call to await fs.open(...)
without a corresponding fs.close
call
Currently the Eventstore implementation provides no way to store events from multiple bounded contexts (where aggregate names may clash).
Need to add a boundedContext
or domain
argument to the constructor to allow the same underlying event store to service multiple domains
The name of this interface is misleading, since it encompasses more than just the aggregate's state - this is made all the more confusing given that it actually has a state
field.
Possible alternatives:
IVersionedAggregateState
IAggregateInstance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.