public static Commit CommitSingle(this IPersistStreams persistence, string streamId = null) { Commit commit = (streamId ?? Guid.NewGuid().ToString()).BuildAttempt(); persistence.Commit(commit); return(commit); }
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); } }
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)); }
public static Commit CommitNext(this IPersistStreams persistence, Commit previous) { Commit commit = previous.BuildNextAttempt(); persistence.Commit(commit); return(commit); }
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(); }
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); }
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); }
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); }
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); }
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); }
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); }
protected override void Because() { _commit2 = _process2.Commit(Guid.NewGuid().ToString().BuildAttempt()); }
public void Commit(Commit attempt) { original.Commit(attempt); }
public Task <ICommit> Commit(CommitAttempt attempt) { return(_original.Commit(attempt)); }
public static ICommit CommitNext(this IPersistStreams persistence, CommitAttempt previous) { var nextAttempt = previous.BuildNextAttempt(); return(persistence.Commit(nextAttempt)); }
public ICommit Commit(CommitAttempt attempt) { return(_original.Commit(attempt)); }
public ICommit Commit(CommitAttempt attempt) { return(underlying.Commit(EmulateSerializationDeserialization(attempt))); }