public new void When() { _distibutionPointCorrelationId = Guid.NewGuid(); _fakeTimeProvider = new FakeTimeProvider(); _edp = new TransactionFileEventReader( _ioDispatcher, _bus, _distibutionPointCorrelationId, null, new TFPos(100, 50), _fakeTimeProvider, deliverEndOfTFPosition: false); _edp.Resume(); _firstEventId = Guid.NewGuid(); _secondEventId = Guid.NewGuid(); _edp.Handle( new ClientMessage.ReadAllEventsForwardCompleted( _distibutionPointCorrelationId, ReadAllResult.Success, null, new[] { new ResolvedEvent( new EventRecord( 1, 50, Guid.NewGuid(), _firstEventId, 50, 0, "a", ExpectedVersion.Any, _fakeTimeProvider.Now, PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd, "event_type1", new byte[] {1}, new byte[] {2}), null, 100), new ResolvedEvent( new EventRecord( 2, 150, Guid.NewGuid(), _secondEventId, 150, 0, "a", ExpectedVersion.Any, _fakeTimeProvider.Now, PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd, SystemEventTypes.StreamDeleted, new byte[] {1}, new byte[] {2}), null, 200), }, null, false, 100, new TFPos(200, 150), new TFPos(500, -1), new TFPos(100, 50), 500)); }
public IEventReader CreatePausedEventReader( Guid eventReaderId, IPublisher publisher, IODispatcher ioDispatcher, CheckpointTag checkpointTag, bool stopOnEof, int?stopAfterNEvents) { if (_allStreams && _events != null && _events.Count >= 1) { //IEnumerable<string> streams = GetEventIndexStreams(); return(CreatePausedEventIndexEventReader( eventReaderId, ioDispatcher, publisher, checkpointTag, stopOnEof, stopAfterNEvents, true, _events, _includeStreamDeletedNotification)); } if (_allStreams) { var eventReader = new TransactionFileEventReader(publisher, eventReaderId, _runAs, new TFPos(checkpointTag.CommitPosition.Value, checkpointTag.PreparePosition.Value), _timeProvider, deliverEndOfTFPosition: true, stopOnEof: stopOnEof, resolveLinkTos: false); return(eventReader); } if (_streams != null && _streams.Count == 1) { var streamName = checkpointTag.Streams.Keys.First(); //TODO: handle if not the same return(CreatePausedStreamEventReader( eventReaderId, ioDispatcher, publisher, checkpointTag, streamName, stopOnEof, resolveLinkTos: true, stopAfterNEvents: stopAfterNEvents, produceStreamDeletes: _includeStreamDeletedNotification)); } if (_categories != null && _categories.Count == 1) { var streamName = checkpointTag.Streams.Keys.First(); return(CreatePausedStreamEventReader( eventReaderId, ioDispatcher, publisher, checkpointTag, streamName, stopOnEof, resolveLinkTos: true, stopAfterNEvents: stopAfterNEvents, produceStreamDeletes: _includeStreamDeletedNotification)); } if (_streams != null && _streams.Count > 1) { return(CreatePausedMultiStreamEventReader( eventReaderId, ioDispatcher, publisher, checkpointTag, stopOnEof, stopAfterNEvents, true, _streams)); } if (!string.IsNullOrEmpty(_catalogStream)) { return(CreatePausedCatalogReader( eventReaderId, publisher, ioDispatcher, checkpointTag, stopOnEof, stopAfterNEvents, true, _catalogStream)); } throw new NotSupportedException(); }
private void StartReaders() { //TODO: do we need to clear subscribed projections here? //TODO: do we need to clear subscribed distribution points here? _stopped = false; var distributionPointCorrelationId = Guid.NewGuid(); var transactionFileReader = new TransactionFileEventReader( _ioDispatcher, _publisher, distributionPointCorrelationId, SystemAccount.Principal, new TFPos(_writerCheckpoint.Read(), -1), new RealTimeProvider(), deliverEndOfTFPosition: false); _eventReaders.Add(distributionPointCorrelationId, transactionFileReader); if (_runHeadingReader) { _headingEventReader.Start(distributionPointCorrelationId, transactionFileReader); } }
public new void When() { _distibutionPointCorrelationId = Guid.NewGuid(); _fakeTimeProvider = new FakeTimeProvider(); _edp = new TransactionFileEventReader(_bus, _distibutionPointCorrelationId, null, new TFPos(100, 50), _fakeTimeProvider, deliverEndOfTFPosition: false); _edp.Resume(); _firstEventId = Guid.NewGuid(); _secondEventId = Guid.NewGuid(); _edp.Handle( new ClientMessage.ReadAllEventsForwardCompleted( _distibutionPointCorrelationId, ReadAllResult.Success, null, new[] { EventStore.Core.Data.ResolvedEvent.ForUnresolvedEvent( new EventRecord( 1, 50, Guid.NewGuid(), _firstEventId, 50, 0, "a", ExpectedVersion.Any, _fakeTimeProvider.Now, PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd, "event_type1", new byte[] {1}, new byte[] {2}), 100), EventStore.Core.Data.ResolvedEvent.ForUnresolvedEvent( new EventRecord( 2, 150, Guid.NewGuid(), _secondEventId, 150, 0, "b", ExpectedVersion.Any, _fakeTimeProvider.Now, PrepareFlags.SingleWrite | PrepareFlags.TransactionBegin | PrepareFlags.TransactionEnd, "event_type1", new byte[] {1}, new byte[] {2}), 200), }, null, false, 100, new TFPos(200, 150), new TFPos(500, -1), new TFPos(100, 50), 500)); _edp.Handle( new ClientMessage.ReadAllEventsForwardCompleted( _distibutionPointCorrelationId, ReadAllResult.Success, null, new EventStore.Core.Data.ResolvedEvent[0], null, false, 100, new TFPos(), new TFPos(), new TFPos(), 500)); _fakeTimeProvider.AddTime(TimeSpan.FromMilliseconds(500)); _edp.Handle( new ClientMessage.ReadAllEventsForwardCompleted( _distibutionPointCorrelationId, ReadAllResult.Success, null, new EventStore.Core.Data.ResolvedEvent[0], null, false, 100, new TFPos(), new TFPos(), new TFPos(), 500)); }
public IEventReader CreatePausedEventReader( Guid eventReaderId, IPublisher publisher, IODispatcher ioDispatcher, CheckpointTag checkpointTag, bool stopOnEof, int? stopAfterNEvents) { if (_allStreams && _events != null && _events.Count >= 1) { //IEnumerable<string> streams = GetEventIndexStreams(); return CreatePausedEventIndexEventReader( eventReaderId, publisher, checkpointTag, stopOnEof, stopAfterNEvents, true, _events); } if (_allStreams) { var eventReader = new TransactionFileEventReader( publisher, eventReaderId, _runAs, new TFPos(checkpointTag.CommitPosition.Value, checkpointTag.PreparePosition.Value), _timeProvider, deliverEndOfTFPosition: true, stopOnEof: stopOnEof, resolveLinkTos: false, stopAfterNEvents: stopAfterNEvents); return eventReader; } if (_streams != null && _streams.Count == 1) { var streamName = checkpointTag.Streams.Keys.First(); //TODO: handle if not the same return CreatePausedStreamEventReader( eventReaderId, publisher, checkpointTag, streamName, stopOnEof, resolveLinkTos: true, stopAfterNEvents: stopAfterNEvents); } if (_categories != null && _categories.Count == 1) { var streamName = checkpointTag.Streams.Keys.First(); return CreatePausedStreamEventReader( eventReaderId, publisher, checkpointTag, streamName, stopOnEof, resolveLinkTos: true, stopAfterNEvents: stopAfterNEvents); } if (_streams != null && _streams.Count > 1) { return CreatePausedMultiStreamEventReader( eventReaderId, publisher, checkpointTag, stopOnEof, stopAfterNEvents, true, _streams); } if (!string.IsNullOrEmpty(_catalogStream)) { return CreatePausedCatalogReader( eventReaderId, publisher, ioDispatcher, checkpointTag, stopOnEof, stopAfterNEvents, true, _catalogStream); } throw new NotSupportedException(); }
public EventReader CreatePausedEventReader( Guid eventReaderId, IPublisher publisher, CheckpointTag checkpointTag, bool stopOnEof) { if (_allStreams && _useEventIndexes && _events != null && _events.Count == 1) { var streamName = checkpointTag.Streams.Keys.First(); return CreatePausedStreamEventReader( eventReaderId, publisher, checkpointTag, streamName, stopOnEof, resolveLinkTos: true); } if (_allStreams && _useEventIndexes && _events != null && _events.Count > 1) { IEnumerable<string> streams = GetEventIndexStreams(); return CreatePausedEventIndexEventReader( eventReaderId, publisher, checkpointTag, stopOnEof, true, streams); } if (_allStreams) { var eventReader = new TransactionFileEventReader( publisher, eventReaderId, new EventPosition(checkpointTag.CommitPosition.Value, checkpointTag.PreparePosition.Value), new RealTimeProvider(), deliverEndOfTFPosition: true, stopOnEof: stopOnEof); return eventReader; } if (_streams != null && _streams.Count == 1) { var streamName = checkpointTag.Streams.Keys.First(); //TODO: handle if not the same return CreatePausedStreamEventReader( eventReaderId, publisher, checkpointTag, streamName, stopOnEof, resolveLinkTos: true); } if (_categories != null && _categories.Count == 1) { var streamName = checkpointTag.Streams.Keys.First(); return CreatePausedStreamEventReader( eventReaderId, publisher, checkpointTag, streamName, stopOnEof, resolveLinkTos: true); } if (_streams != null && _streams.Count > 1) { return CreatePausedMultiStreamEventReader( eventReaderId, publisher, checkpointTag, stopOnEof, true, _streams); } throw new NotSupportedException(); }