예제 #1
0
        public static Commit CommitSingle(this IPersistStreams persistence, string streamId = null)
        {
            Commit commit = (streamId ?? Guid.NewGuid().ToString()).BuildAttempt();

            persistence.Commit(commit);
            return(commit);
        }
예제 #2
0
        public virtual void Commit(Commit attempt)
        {
            if (!attempt.IsValid() || attempt.IsEmpty())
            {
                Logger.Debug(Resources.CommitAttemptFailedIntegrityChecks);
                return;
            }

            foreach (var hook in _pipelineHooks)
            {
                Logger.Debug(Resources.InvokingPreCommitHooks, attempt.CommitId, hook.GetType());
                if (hook.PreCommit(attempt))
                {
                    continue;
                }

                Logger.Info(Resources.CommitRejectedByPipelineHook, hook.GetType(), attempt.CommitId);
                return;
            }

            Logger.Info(Resources.CommittingAttempt, attempt.CommitId, attempt.Events.Count);
            _persistence.Commit(attempt);

            foreach (var hook in _pipelineHooks)
            {
                Logger.Debug(Resources.InvokingPostCommitPipelineHooks, attempt.CommitId, hook.GetType());
                hook.PostCommit(attempt);
            }
        }
예제 #3
0
        public static Task <ICommit> CommitSingle(this IPersistStreams persistence, string streamId = null, DateTime?now = null)
        {
            CommitAttempt commitAttempt = (streamId ?? Guid.NewGuid().ToString())
                                          .BuildAttempt(now: now);

            return(persistence.Commit(commitAttempt));
        }
예제 #4
0
        public static Commit CommitNext(this IPersistStreams persistence, Commit previous)
        {
            Commit commit = previous.BuildNextAttempt();

            persistence.Commit(commit);
            return(commit);
        }
예제 #5
0
        public virtual ICommit Commit(CommitAttempt attempt)
        {
            Guard.NotNull(() => attempt, attempt);
            foreach (var hook in _pipelineHooks)
            {
                Logger.Debug(Resources.InvokingPreCommitHooks, attempt.CommitId, hook.GetType());
                if (hook.PreCommit(attempt))
                {
                    continue;
                }

                Logger.Info(Resources.CommitRejectedByPipelineHook, hook.GetType(), attempt.CommitId);
                return(null);
            }

            Logger.Info(Resources.CommittingAttempt, attempt.CommitId, attempt.Events.Count);
            ICommit commit = _persistence.Commit(attempt);

            foreach (var hook in _pipelineHooks)
            {
                Logger.Debug(Resources.InvokingPostCommitPipelineHooks, attempt.CommitId, hook.GetType());
                hook.PostCommit(commit);
            }
            return(commit);
        }
 protected override void Context()
 {
     snapshot     = new Snapshot(streamId, 1, "Snapshot");
     persistence1 = Partitions.NewEventStoreWithPartition();
     persistence2 = Partitions.NewEventStoreWithPartition();
     persistence1.Commit(streamId.BuildAttempt());
 }
        protected override void Context()
        {
            persistence1 = Partitions.NewEventStoreWithPartition();
            persistence2 = Partitions.NewEventStoreWithPartition();

            persistence1.Commit(streamId.BuildAttempt());
            persistence2.Commit(streamId.BuildAttempt());
        }
        protected override async Task Context()
        {
            _process1 = new AcceptanceTestMongoPersistenceFactory().Build();
            await _process1.Initialize();
            _commit1 = await _process1.Commit(Guid.NewGuid().ToString().BuildAttempt());

            _process2 = new AcceptanceTestMongoPersistenceFactory().Build();
            await _process2.Initialize();
        }
예제 #9
0
        protected override void Context()
        {
            _process1 = new AcceptanceTestMongoPersistenceFactory().Build();
            _process1.Initialize();
            _commit1 = _process1.Commit(Guid.NewGuid().ToString().BuildAttempt());

            _process2 = new AcceptanceTestMongoPersistenceFactory().Build();
            _process2.Initialize();
        }
        protected override void Context()
        {
            now    = SystemTime.UtcNow.AddYears(1);
            first  = Guid.NewGuid().BuildAttempt(now.AddSeconds(1));
            second = first.BuildNextAttempt();
            third  = second.BuildNextAttempt();
            fourth = third.BuildNextAttempt();
            fifth  = Guid.NewGuid().BuildAttempt(now.AddSeconds(1));

            persistence1 = Partitions.NewEventStoreWithPartition();
            persistence2 = Partitions.NewEventStoreWithPartition();

            persistence1.Commit(first);
            persistence1.Commit(second);
            persistence1.Commit(third);
            persistence1.Commit(fourth);
            persistence2.Commit(fifth);
        }
        protected override void Context()
        {
            _now    = SystemTime.UtcNow.AddYears(1);
            _first  = Guid.NewGuid().BuildAttempt(_now.AddSeconds(1));
            _second = _first.BuildNextAttempt();
            _third  = _second.BuildNextAttempt();
            _fourth = _third.BuildNextAttempt();
            _fifth  = Guid.NewGuid().BuildAttempt(_now.AddSeconds(1));

            _persistence1 = Partitions.NewEventStoreWithPartition();
            _persistence2 = Partitions.NewEventStoreWithPartition();

            _persistence1.Commit(_first);
            _persistence1.Commit(_second);
            _persistence1.Commit(_third);
            _persistence1.Commit(_fourth);
            _persistence2.Commit(_fifth);
        }
예제 #12
0
        public ICommit Commit(CommitAttempt attempt)
        {
            Stopwatch clock  = Stopwatch.StartNew();
            ICommit   commit = _persistence.Commit(attempt);

            clock.Stop();
            _counters.CountCommit(attempt.Events.Count, clock.ElapsedMilliseconds);
            return(commit);
        }
        public virtual void Commit(Commit attempt)
        {
            Stopwatch clock = Stopwatch.StartNew();

            _persistence.Commit(attempt);
            clock.Stop();

            _counters.CountCommit(attempt.Events.Count, clock.ElapsedMilliseconds);
        }
예제 #14
0
        public static void CommitMany(this IPersistStreams persistence, int numberOfCommits, Guid?streamId = null)
        {
            Commit attempt = null;

            for (int i = 0; i < numberOfCommits; i++)
            {
                attempt = attempt == null ? (streamId ?? Guid.NewGuid()).BuildAttempt() : attempt.BuildNextAttempt();
                persistence.Commit(attempt);
            }
        }
        protected override void Context()
        {
            persistence1 = Partitions.NewEventStoreWithPartition();
            persistence2 = Partitions.NewEventStoreWithPartition();

            var now = SystemTime.UtcNow;

            attempt1 = streamId.BuildAttempt(now);
            attempt2 = streamId.BuildAttempt(now.Subtract(TimeSpan.FromDays(1)));

            persistence1.Commit(attempt1);
        }
예제 #16
0
        public static IEnumerable <Commit> CommitMany(this IPersistStreams persistence, int numberOfCommits, string streamId = null)
        {
            var    commits = new List <Commit>();
            Commit attempt = null;

            for (int i = 0; i < numberOfCommits; i++)
            {
                attempt = attempt == null ? (streamId ?? Guid.NewGuid().ToString()).BuildAttempt() : attempt.BuildNextAttempt();
                persistence.Commit(attempt);
                commits.Add(attempt);
            }

            return(commits);
        }
예제 #17
0
        public static async Task <IEnumerable <CommitAttempt> > CommitMany(this IPersistStreams persistence,
                                                                           int numberOfCommits, string streamId = null, string bucketId = null, DateTime?now = null)
        {
            var           commits = new List <CommitAttempt>();
            CommitAttempt attempt = null;

            for (int i = 0; i < numberOfCommits; i++)
            {
                attempt = attempt == null ? (streamId ?? Guid.NewGuid().ToString()).BuildAttempt(now, bucketId) : attempt.BuildNextAttempt();
                await persistence.Commit(attempt);

                commits.Add(attempt);
            }

            return(commits);
        }
예제 #18
0
        protected override void Context()
        {
            _streamId = Guid.NewGuid();
            _commit   = new Commit(_streamId,
                                   2,
                                   Guid.NewGuid(),
                                   1,
                                   DateTime.Now,
                                   new Dictionary <string, object> {
                { "key.1", "value" }
            },
                                   new List <EventMessage> {
                new EventMessage {
                    Body = new ExtensionMethods.SomeDomainEvent {
                        SomeProperty = "Test"
                    }
                }
            });
            IPersistStreams persistence = Persistence;

            persistence.Commit(_commit);
        }
예제 #19
0
 protected override void Because()
 {
     _commit2 = _process2.Commit(Guid.NewGuid().ToString().BuildAttempt());
 }
예제 #20
0
 public void Commit(Commit attempt)
 {
     original.Commit(attempt);
 }
예제 #21
0
 public Task <ICommit> Commit(CommitAttempt attempt)
 {
     return(_original.Commit(attempt));
 }
예제 #22
0
        public static ICommit CommitNext(this IPersistStreams persistence, CommitAttempt previous)
        {
            var nextAttempt = previous.BuildNextAttempt();

            return(persistence.Commit(nextAttempt));
        }
예제 #23
0
 public ICommit Commit(CommitAttempt attempt)
 {
     return(_original.Commit(attempt));
 }
 public ICommit Commit(CommitAttempt attempt)
 {
     return(underlying.Commit(EmulateSerializationDeserialization(attempt)));
 }