Example #1
0
        public Task <IReadOnlyList <IEvent> > FetchStreamAsync(Guid streamId, long version = 0, DateTime?timestamp = null, long fromVersion = 0, CancellationToken token = default)
        {
            var selector = _store.Events.EnsureAsGuidStorage(_session);

            var statement = new EventStatement(selector)
            {
                StreamId = streamId, Version = version, Timestamp = timestamp, TenantId = _tenant.TenantId, FromVersion = fromVersion
            };

            IQueryHandler <IReadOnlyList <IEvent> > handler = new ListQueryHandler <IEvent>(statement, selector);

            return(_session.ExecuteHandlerAsync(handler, token));
        }
Example #2
0
        public async Task <IReadOnlyList <IEvent> > FetchStreamAsync(Guid streamId, long version = 0, DateTimeOffset?timestamp = null, long fromVersion = 0, CancellationToken token = default)
        {
            var selector = _store.Events.EnsureAsGuidStorage(_session);

            await _tenant.Database.EnsureStorageExistsAsync(typeof(IEvent), token).ConfigureAwait(false);

            var statement = new EventStatement(selector)
            {
                StreamId = streamId, Version = version, Timestamp = timestamp, TenantId = _tenant.TenantId, FromVersion = fromVersion
            };

            IQueryHandler <IReadOnlyList <IEvent> > handler = new ListQueryHandler <IEvent>(statement, selector);

            return(await _session.ExecuteHandlerAsync(handler, token).ConfigureAwait(false));
        }
Example #3
0
        public async Task Load(EventRange range, CancellationToken token)
        {
            if (_session == null)
            {
                reset();
            }

            _cancellation.CancelAfter(5.Seconds());

            // There's an assumption here that this method is only called sequentially
            // and never at the same time on the same instance
            _statement.Range = range;

            range.Events = await _session.ExecuteHandlerAsync(_handler, token);
        }
Example #4
0
        public async Task Load(ShardName projectionShardName, EventRange range, CancellationToken token)
        {
            if (_session == null)
            {
                reset();
            }

            _cancellation.CancelAfter(5.Seconds());

            // There's an assumption here that this method is only called sequentially
            // and never at the same time on the same instance
            _statement.Range = range;

            try
            {
                range.Events = await _session.ExecuteHandlerAsync(_handler, token);
            }
            catch (Exception e)
            {
                throw new EventFetcherException(projectionShardName, e);
            }
        }