protected abstract Task <IStreamSubscription> SubscribeToStreamInternal( string streamId, int startVersion, StreamEventReceived streamEventReceived, SubscriptionDropped subscriptionDropped, string name, CancellationToken cancellationToken);
public async Task When_exception_throw_by_subscription_event_received_then_should_drop_subscription() { using (var store = new InMemoryEventStore()) { var eventReceivedException = new TaskCompletionSource <Exception>(); StreamEventReceived eventReceived = _ => { throw new Exception(); }; SubscriptionDropped subscriptionDropped = (reason, exception) => { eventReceivedException.SetResult(exception); }; string streamId = "stream-1"; using (await store.SubscribeToStream("stream-1", StreamVersion.Start, eventReceived, subscriptionDropped)) { await store.AppendToStream(streamId, ExpectedVersion.NoStream, new NewStreamEvent(Guid.NewGuid(), "type", "{}")); var dropException = await eventReceivedException.Task.WithTimeout(); dropException.ShouldBeOfType <Exception>(); } } }
protected SubscriptionBase( IReadOnlyEventStore readOnlyEventStore, IObservable <Unit> eventStoreAppendedNotification, StreamEventReceived streamEventReceived, SubscriptionDropped subscriptionDropped = null, string name = null) { ReadOnlyEventStore = readOnlyEventStore; EventStoreAppendedNotification = eventStoreAppendedNotification; StreamEventReceived = streamEventReceived; Name = string.IsNullOrWhiteSpace(name) ? Guid.NewGuid().ToString() : name; SubscriptionDropped = subscriptionDropped ?? ((_, __) => { }); }
public AllStreamSubscription( long?fromCheckpoint, IReadOnlyEventStore readOnlyEventStore, IObservable <Unit> eventStoreAppendedNotification, StreamEventReceived streamEventReceived, SubscriptionDropped subscriptionDropped = null, string name = null) : base(readOnlyEventStore, eventStoreAppendedNotification, streamEventReceived, subscriptionDropped, name) { FromCheckpoint = fromCheckpoint; LastCheckpoint = fromCheckpoint; _nextCheckpoint = fromCheckpoint + 1 ?? Checkpoint.Start; }
public StreamSubscription( string streamId, int startVersion, IReadOnlyEventStore readOnlyEventStore, IObservable <Unit> eventStoreAppendedNotification, StreamEventReceived streamEventReceived, SubscriptionDropped subscriptionDropped, string name = null) : base(readOnlyEventStore, eventStoreAppendedNotification, streamEventReceived, subscriptionDropped, name) { _streamId = streamId; _nextVersion = startVersion; _lastVersion = startVersion - 1; }
public Task <IAllStreamSubscription> SubscribeToAll( long?fromCheckpointExclusive, StreamEventReceived streamEventReceived, SubscriptionDropped subscriptionDropped = null, string name = null, CancellationToken cancellationToken = default(CancellationToken)) { Ensure.That(streamEventReceived, nameof(streamEventReceived)).IsNotNull(); CheckIfDisposed(); return(SubscribeToAllInternal(fromCheckpointExclusive, streamEventReceived, subscriptionDropped, name, cancellationToken)); }
protected override async Task <IAllStreamSubscription> SubscribeToAllInternal( long?fromCheckpoint, StreamEventReceived streamEventReceived, SubscriptionDropped subscriptionDropped, string name, CancellationToken cancellationToken) { var subscription = new AllStreamSubscription( fromCheckpoint, this, _subscriptions, streamEventReceived, subscriptionDropped, name); await subscription.Start(cancellationToken); return(subscription); }
public Task <IStreamSubscription> SubscribeToStream( string streamId, int fromVersionExclusive, StreamEventReceived streamEventReceived, SubscriptionDropped subscriptionDropped = null, string name = null, CancellationToken cancellationToken = default(CancellationToken)) { Ensure.That(streamId, nameof(streamId)).IsNotNullOrWhiteSpace(); Ensure.That(streamEventReceived, nameof(streamEventReceived)).IsNotNull(); CheckIfDisposed(); return(SubscribeToStreamInternal(streamId, fromVersionExclusive, streamEventReceived, subscriptionDropped, name, cancellationToken)); }
protected override async Task <IStreamSubscription> SubscribeToStreamInternal( string streamId, int startVersion, StreamEventReceived streamEventReceived, SubscriptionDropped subscriptionDropped, string name, CancellationToken cancellationToken) { var subscription = new StreamSubscription( streamId, startVersion, this, _subscriptions, streamEventReceived, subscriptionDropped, name); await subscription.Start(cancellationToken); return(subscription); }
protected abstract Task <IAllStreamSubscription> SubscribeToAllInternal( long?fromCheckpoint, StreamEventReceived streamEventReceived, SubscriptionDropped subscriptionDropped, string name, CancellationToken cancellationToken);