Giter VIP home page Giter VIP logo

event-sourcing-kit's People

Contributors

dependabot[bot] avatar jwindridge avatar

Watchers

 avatar

event-sourcing-kit's Issues

Add support for aggregate snapshots

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.

Allow for handling of concurrency errors

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 applied
  • expectedState: State of the aggregate at the version expected by the command
  • savedEvents: Array of the events that have been saved to the aggregate between the expected & current versions
  • newEvents: Array of the domain events that caused the AppendOnlyStoreConcurrencyError

Function 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.

Event store should be able to support multiple bounded contexts

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

Consider renaming `IAggregateState` interface

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.