Ejemplo n.º 1
0
        /// <summary>
        /// Gets all commits for the specified <paramref name="streamId"/> with a version greater than or equal to <paramref name="minimumVersion"/>.
        /// </summary>
        /// <param name="streamId">The unique stream identifier.</param>
        /// <param name="minimumVersion">The minimum stream version (inclusive).</param>
        public IEnumerable <Commit> GetStream(Guid streamId, Int32 minimumVersion)
        {
            var result = eventStore.GetStream(streamId, minimumVersion);

            statistics.IncrementQueryCount();

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Retrieve the aggregate of the specified <paramref name="aggregateType"/> and aggregate <paramref name="id"/>.
        /// </summary>
        /// <param name="aggregateType">The type of aggregate to retrieve.</param>
        /// <param name="id">The unique aggregate id.</param>
        public Aggregate Get(Type aggregateType, Guid id)
        {
            Verify.NotNull(aggregateType, nameof(aggregateType));
            Verify.TypeDerivesFrom(typeof(Aggregate), aggregateType, nameof(aggregateType));

            var aggregate = GetOrCreate(aggregateType, id);
            var originalAggregateVersion = aggregate.Version;
            var commits = eventStore.GetStream(id, aggregate.Version + 1);

            foreach (var commit in commits)
            {
                ApplyCommitToAggregate(commit, aggregate);
            }

            if (aggregate.Version - originalAggregateVersion >= snapshotInterval)
            {
                snapshotStore.Save(new Snapshot(aggregate.Id, aggregate.Version, aggregate));
            }

            return(aggregate);
        }
Ejemplo n.º 3
0
 protected Task <IEventStream> OpenStream(String bucket, String streamId, ISnapshot snapshot = null)
 {
     return(_store.GetStream <T>(bucket, streamId, snapshot?.Version + 1));
 }