public static Task <ICommit> CommitNextAsync(
            this IPersistStreams persistence, CommitAttempt previous, CancellationToken cancellationToken)
        {
            var nextAttempt = previous.BuildNextAttempt();

            return(persistence.CommitAsync(nextAttempt, cancellationToken));
        }
Ejemplo n.º 2
0
 protected override void Because()
 {
     try
     {
         Persistence.Commit(_streamId.BuildAttempt());
         throw new Exception("Previous message should throw concurrency exception");
     }
     catch (ConcurrencyException)
     {
         //do nothing.
     }
     Persistence.Commit(_attempt.BuildNextAttempt());
 }
        public static async Task <IEnumerable <CommitAttempt> > CommitManyAsync(
            this IPersistStreams persistence, int numberOfCommits, string streamId, string bucketId, CancellationToken cancellationToken)
        {
            var           commits = new List <CommitAttempt>();
            CommitAttempt attempt = null;

            for (var i = 0; i < numberOfCommits; i++)
            {
                cancellationToken.ThrowIfCancellationRequested();

                attempt = attempt == null
                    ? (streamId ?? Guid.NewGuid().ToString()).BuildAttempt(null, bucketId)
                    : attempt.BuildNextAttempt();

                await persistence.CommitAsync(attempt, cancellationToken).ConfigureAwait(false);

                commits.Add(attempt);
            }

            return(commits);
        }
Ejemplo n.º 4
0
        public static IEnumerable <CommitAttempt> CommitMany(this IPersistStreams persistence, int numberOfCommits, string streamId = null, string bucketId = null)
        {
            var           commits = new List <CommitAttempt>();
            CommitAttempt attempt = null;

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

            return(commits);
        }
Ejemplo n.º 5
0
        public static ICommit CommitNext(this IPersistStreams persistence, CommitAttempt previous)
        {
            var nextAttempt = previous.BuildNextAttempt();

            return(persistence.Commit(nextAttempt));
        }