Exemple #1
0
        public async Task <AppendResult> AppendToStream(
            StreamId streamId,
            int expectedVersion,
            NewStreamMessage[] messages,
            CancellationToken cancellationToken = new CancellationToken())
        {
            var span = _spanSource.Begin("stream-store." + nameof(AppendToStream), ServiceName, streamId, TypeName);

            try
            {
                return(await _streamStore
                       .AppendToStream(
                           streamId,
                           expectedVersion,
                           messages,
                           cancellationToken));
            }
            catch (Exception ex)
            {
                span?.SetError(ex);
                throw;
            }
            finally
            {
                span?.Dispose();
            }
        }
Exemple #2
0
 public async Task <AppendResult> AppendToStream(
     StreamId streamId,
     int expectedVersion,
     NewStreamMessage[] messages,
     CancellationToken cancellationToken = new CancellationToken())
 => await Trace(
     nameof(AppendToStream),
     streamId,
     () => _streamStore.AppendToStream(streamId, expectedVersion, messages, cancellationToken));
Exemple #3
0
        public async Task Save(Loan loan)
        {
            var streamId        = GetStreamId(loan.Id);
            var events          = loan.GetUncommittedEvents();
            var expectedVersion = loan.Version - events.Length;
            var eventStore      = new MsSqlStreamStore(new MsSqlStreamStoreSettings("myconnectionString"));
            var messages        = events.Select(Serialize).ToArray();
            await eventStore.AppendToStream(streamId, expectedVersion, messages);

            loan.ClearUncommittedEvents();
        }