Ejemplo n.º 1
0
        public async Task Append(string tenantId, Guid entityId, Guid commitId, params object[] events)
        {
            tenantId.MustNotBeEmpty();
            entityId.MustNotBeDefault();
            commitId.MustNotBeDefault();
            if (events.IsNullOrEmpty())
            {
                return;
            }

            var commit  = new UnversionedCommit(tenantId, entityId, Utils.PackEvents(events), commitId, DateTimeOffset.Now);
            var dbgInfo = new{ tenantId, entityId, commitId };

            EventStore.Logger.Debug("Appending {@commit} with events {@events}", dbgInfo, events);
            var rez = await _store.Append(commit);

            if (rez.WasSuccessful)
            {
                EventStore.Logger.Debug("Append succesful for commit {@commit}", dbgInfo);
                return;
            }
            throw new DuplicateCommitException(commitId, Utils.UnpackEvents(commit.Timestamp, commit.EventData, _settings.EventMappers));
        }
Ejemplo n.º 2
0
        public Commit Rewrite(Commit commit)
        {
            var evs = Utils.UnpackEvents(commit.Timestamp, commit.EventData, _mapps);

            return(new Commit(commit.TenantId, commit.EntityId, Utils.PackEvents(evs), commit.CommitId, commit.Timestamp, commit.Version));
        }
Ejemplo n.º 3
0
 public static IEnumerable <Commit> Commits <T, V>(int count) where T : class, new() where V : class, new()
 {
     return(Enumerable.Range(1, count)
            .Select(i => new Commit("_", Setup.EntityId, Utils.PackEvents(new Object[] { new T(), new V() }), Guid.NewGuid(), DateTimeOffset.Now, i)));
 }
Ejemplo n.º 4
0
 public static UnversionedCommit UnversionedCommit(string tenantId = "_", Guid?guid = null)
 =>
 new UnversionedCommit(tenantId, guid ?? Guid.NewGuid(), Utils.PackEvents(Events(1)), Guid.NewGuid(),
                       DateTimeOffset.Now);
Ejemplo n.º 5
0
 public static Commit Commit(params object[] events) => new Commit("_", Guid.NewGuid(), Utils.PackEvents(events), Guid.NewGuid(), DateTimeOffset.Now, 1);