protected override IStreamSubscription SubscribeToStreamInternal( string streamId, int?startVersion, StreamMessageReceived streamMessageReceived, SubscriptionDropped subscriptionDropped, HasCaughtUp hasCaughtUp, bool prefetchJsonData, string name) { throw new NotImplementedException(); }
protected SubscriptionBase( IReadonlyStreamStore readonlyStreamStore, IObservable <Unit> streamStoreAppendedNotification, StreamMessageReceived streamMessageReceived, SubscriptionDropped subscriptionDropped = null, string name = null) { ReadonlyStreamStore = readonlyStreamStore; StreamStoreAppendedNotification = streamStoreAppendedNotification; StreamMessageReceived = streamMessageReceived; 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 AllStreamSubscription( long?fromPosition, IReadonlyStreamStore readonlyStreamStore, IObservable <Unit> streamStoreAppendedNotification, StreamMessageReceived streamMessageReceived, SubscriptionDropped subscriptionDropped = null, string name = null) : base(readonlyStreamStore, streamStoreAppendedNotification, streamMessageReceived, subscriptionDropped, name) { FromPosition = fromPosition; LastPosition = fromPosition; _nextPosition = fromPosition + 1 ?? Position.Start; }
public StreamSubscription( string streamId, int startVersion, IReadonlyStreamStore readonlyStreamStore, IObservable <Unit> streamStoreAppendedNotification, StreamMessageReceived streamMessageReceived, SubscriptionDropped subscriptionDropped, string name = null) : base(readonlyStreamStore, streamStoreAppendedNotification, streamMessageReceived, 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 IStreamSubscription SubscribeToStreamInternal( string streamId, int?startVersion, StreamMessageReceived streamMessageReceived, SubscriptionDropped subscriptionDropped, HasCaughtUp hasCaughtUp, bool prefetchJsonData, string name) => new StreamSubscription( streamId, startVersion, this, GetStoreObservable, streamMessageReceived, subscriptionDropped, hasCaughtUp, prefetchJsonData, name);
public IStreamSubscription SubscribeToStream( StreamId streamId, int?continueAfterVersion, StreamMessageReceived streamMessageReceived, SubscriptionDropped subscriptionDropped = null, HasCaughtUp hasCaughtUp = null, bool prefetchJsonData = true, string name = null) => new StreamSubscription( streamId, continueAfterVersion, this, _streamStoreNotifier.Value, streamMessageReceived, subscriptionDropped, hasCaughtUp, prefetchJsonData, name);
protected override IStreamSubscription SubscribeToStreamInternal( string streamId, int?startVersion, StreamMessageReceived streamMessageReceived, SubscriptionDropped subscriptionDropped, HasCaughtUp hasCaughtUp, string name) { return(new StreamSubscription( streamId, startVersion, this, GetStoreObservable, streamMessageReceived, subscriptionDropped, hasCaughtUp, name)); }
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 IStreamSubscription SubscribeToStream( StreamId streamId, int?continueAfterVersion, StreamMessageReceived streamMessageReceived, SubscriptionDropped subscriptionDropped = null, HasCaughtUp hasCaughtUp = null, bool prefetchJsonData = true, string name = null) { return(_streamStore .SubscribeToStream( streamId, continueAfterVersion, streamMessageReceived, subscriptionDropped, hasCaughtUp, prefetchJsonData, name)); }
protected override async Task <bool> DoFetch() { var allMessagesPage = await ReadonlyStreamStore .ReadAllForwards( _nextPosition, PageSize, IsDisposed) .NotOnCapturedContext(); bool isEnd = allMessagesPage.IsEnd; foreach (var streamMessage in allMessagesPage.Messages) { if (IsDisposed.IsCancellationRequested) { return(true); } try { await StreamMessageReceived(streamMessage).NotOnCapturedContext(); LastPosition = streamMessage.Position; _nextPosition = streamMessage.Position + 1; } catch (Exception ex) { try { SubscriptionDropped.Invoke(ex.Message, ex); } catch { //TODO logging } finally { Dispose(); } } } return(isEnd); }
protected override async Task <IAllStreamSubscription> SubscribeToAllInternal( long?fromPosition, StreamMessageReceived streamMessageReceived, SubscriptionDropped subscriptionDropped, string name, CancellationToken cancellationToken) { var subscription = new AllStreamSubscription( fromPosition, this, GetStoreObservable, streamMessageReceived, subscriptionDropped, name); await subscription.Start(cancellationToken); return(subscription); }
protected override async Task <bool> DoFetch() { var allEventsPage = await ReadOnlyEventStore .ReadAllForwards( _nextCheckpoint, PageSize, IsDisposed) .NotOnCapturedContext(); bool isEnd = allEventsPage.IsEnd; foreach (var streamEvent in allEventsPage.StreamEvents) { if (IsDisposed.IsCancellationRequested) { return(true); } try { await StreamEventReceived(streamEvent).NotOnCapturedContext(); LastCheckpoint = streamEvent.Checkpoint; _nextCheckpoint = streamEvent.Checkpoint + 1; } catch (Exception ex) { try { SubscriptionDropped.Invoke(ex.Message, ex); } catch { //TODO logging } finally { Dispose(); } } } return(isEnd); }
protected override async Task <bool> DoFetch() { var streamMessagesPage = await ReadonlyStreamStore .ReadStreamForwards( _streamId, _nextVersion, PageSize, IsDisposed) .NotOnCapturedContext(); bool isEnd = streamMessagesPage.IsEndOfStream; foreach (var message in streamMessagesPage.Messages) { if (IsDisposed.IsCancellationRequested) { return(true); } _nextVersion = message.StreamVersion + 1; _lastVersion = message.StreamVersion; try { await StreamMessageReceived(message).NotOnCapturedContext(); } catch (Exception ex) { try { SubscriptionDropped.Invoke(ex.Message, ex); } catch (Exception ex2) { // Need to log this } finally { Dispose(); } } } return(isEnd); }
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, StreamMessageReceived streamMessageReceived, SubscriptionDropped subscriptionDropped, string name, CancellationToken cancellationToken) { var subscription = new StreamSubscription( streamId, startVersion, this, GetStoreObservable, streamMessageReceived, subscriptionDropped); await subscription.Start(cancellationToken); return(subscription); }
protected override IStreamSubscription SubscribeToStreamInternal( string streamId, int?startVersion, StreamMessageReceived streamMessageReceived, SubscriptionDropped subscriptionDropped, HasCaughtUp hasCaughtUp, bool prefetchJsonData, string name) { return(new StreamSubscription( streamId, startVersion, this, _subscriptions, streamMessageReceived, subscriptionDropped, hasCaughtUp, prefetchJsonData, name)); }
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); }
public IStreamSubscription SubscribeToStream( string streamId, int?continueAfterVersion, StreamMessageReceived streamMessageReceived, SubscriptionDropped subscriptionDropped = null, HasCaughtUp hasCaughtUp = null, string name = null) { Ensure.That(streamId, nameof(streamId)).IsNotNullOrWhiteSpace(); Ensure.That(streamMessageReceived, nameof(streamMessageReceived)).IsNotNull(); GuardAgainstDisposed(); return(SubscribeToStreamInternal( streamId, continueAfterVersion, streamMessageReceived, subscriptionDropped, hasCaughtUp, name)); }
public Task <IStreamSubscription> SubscribeToStream(string streamId, EventReceived eventReceived, SubscriptionDropped subscriptionDropped, CancellationToken cancellationToken) { throw new NotImplementedException(); }
public SubscriptionDropped(SubscriptionDropped.SubscriptionDropReason reason) { Reason = reason; }
protected abstract Task <IAllStreamSubscription> SubscribeToAllInternal( long?fromPosition, StreamMessageReceived streamMessageReceived, SubscriptionDropped subscriptionDropped, string name, CancellationToken cancellationToken);
protected abstract Task <IAllStreamSubscription> SubscribeToAllInternal( long?fromCheckpoint, StreamEventReceived streamEventReceived, SubscriptionDropped subscriptionDropped, string name, CancellationToken cancellationToken);