예제 #1
0
        public async Task <ReadStreamPage> ReadStreamForwards(
            StreamId streamId,
            int fromVersionInclusive,
            int maxCount,
            bool prefetchJsonData = true,
            CancellationToken cancellationToken = new CancellationToken())
        {
            var span = _spanSource.Begin("stream-store." + nameof(ReadStreamForwards), ServiceName, streamId, TypeName);

            try
            {
                return(await _streamStore
                       .ReadStreamForwards(
                           streamId,
                           fromVersionInclusive,
                           maxCount,
                           prefetchJsonData,
                           cancellationToken));
            }
            catch (Exception ex)
            {
                span?.SetError(ex);
                throw;
            }
            finally
            {
                span?.Dispose();
            }
        }
예제 #2
0
 public async Task <ReadStreamPage> ReadStreamForwards(
     StreamId streamId,
     int fromVersionInclusive,
     int maxCount,
     bool prefetchJsonData = true,
     CancellationToken cancellationToken = new CancellationToken())
 => await Trace(
     nameof(ReadStreamForwards),
     streamId,
     () => _streamStore.ReadStreamForwards(streamId, fromVersionInclusive, maxCount, prefetchJsonData, cancellationToken));
예제 #3
0
        public async Task <Loan> Get(Guid id)
        {
            var loan       = new Loan(id);
            var streamId   = GetStreamId(id);
            var eventStore = new MsSqlStreamStore(new MsSqlStreamStoreSettings("myconnectionString"));

            var            position = 0;
            ReadStreamPage page;

            do
            {
                page = await eventStore.ReadStreamForwards(streamId, position, ReadPageSize);

                foreach (var message in page.Messages)
                {
                    var evt = await Deserialize(message);

                    loan.ApplyEvent(evt);
                }
                position = page.NextStreamVersion;
            } while (!page.IsEnd);
            return(loan);
        }