CommonDomain brought in from joliver/CommonDomain - Initial stab at #261 #262

Merged
merged 1 commit into from Oct 1, 2013

Projects

None yet

2 participants

@hyrmn
hyrmn commented Sep 30, 2013

This is an initial import of CommonDomain into NEventStore/CommonDomain.
The goal was to minimize breaking changes for existing CD users who aren't
quite ready to string all the things.

Outstanding issues / work / request for feedback:

  • EventStoreRepository tracks opened snapshots and streams in a local
    dictionary. The key was a guid and came from the IAggregate.Id. It's now
    a string of bucketId and IAggregate.Id. This seems really naive. Since
    IAggregate.Id is still a Guid, this could stay as a Guid as well. Or,
    some sort of Value Object wrapper around bucketId and IAggregate.Id
    might be in order.
  • IRepository allows for loading / saving with or without a bucket
  • The SagaEventStoreRepository is untouched. I haven't used CD for saga
    work so I'm unsure if adding bucketId as a saga parameter is something
    people want. I assume so, but I didn't want to add it without some
    validation
  • I believe I applied the NES code style formatting to all files.
@hyrmn hyrmn CommonDomain brought in from joliver/CommonDomain - Initial stab at #261


This is an initial import of CommonDomain into NEventStore/CommonDomain.
The goal was to minimize breaking changes for existing CD users who aren't
quite ready to string all the things.

Outstanding issues / work / request for feedback:

- EventStoreRepository tracks opened snapshots and streams in a local
  dictionary. The key was a guid and came from the IAggregate.Id. It's now
  a string of bucketId and IAggregate.Id. This seems really naive. Since
  IAggregate.Id is still a Guid, this could stay as a Guid as well. Or,
  some sort of Value Object wrapper around bucketId and IAggregate.Id
  might be in order.

_ IRepository allows for loading / saving with or without a bucket

- The SagaEventStoreRepository is untouched. I haven't used CD for saga
  work so I'm unsure if adding bucketId as a saga parameter is something
  people want. I assume so, but I didn't want to add it without some
  validation

- I believe I applied the NES code style formatting to all files.
9fdf647
@hyrmn hyrmn commented on the diff Sep 30, 2013
...Domain/Persistence/EventStore/EventStoreRepository.cs
+
+ private static void ApplyEventsToAggregate(int versionToLoad, IEventStream stream, IAggregate aggregate)
+ {
+ if (versionToLoad == 0 || aggregate.Version < versionToLoad)
+ {
+ foreach (var @event in stream.CommittedEvents.Select(x => x.Body))
+ {
+ aggregate.ApplyEvent(@event);
+ }
+ }
+ }
+
+ private IAggregate GetAggregate<TAggregate>(ISnapshot snapshot, IEventStream stream)
+ {
+ IMemento memento = snapshot == null ? null : snapshot.Payload as IMemento;
+ return this.factory.Build(typeof(TAggregate), stream.StreamId.ToGuid(), memento);
@hyrmn
hyrmn Sep 30, 2013

The ToGuid() was a premature add. I think this should just be a Guid.Parse.

@damianh
damianh commented Sep 30, 2013

Thx for doing this! Will go through it later today.

@damianh damianh merged commit 59aa91c into NEventStore:master Oct 1, 2013
@damianh
damianh commented Oct 1, 2013

Gave it the once-over, import looks fine. Will need some adjustments, will do in a separate step. Thx Ben.

@hyrmn hyrmn deleted the unknown repository branch Oct 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment