コード例 #1
0
        public IDisposable SubscribeToAllFrom(Position @from, Action <RecordedEvent> eventAppeared, CatchUpSubscriptionSettings settings = null,
                                              Action liveProcessingStarted    = null, Action <SubscriptionDropReason, Exception> subscriptionDropped = null,
                                              UserCredentials userCredentials = null, bool resolveLinkTos = true)
        {
            var current       = (int)@from.CommitPosition;
            var currentEvents = new RecordedEvent[] { };

            lock (_allStream) {
                if (@from == Position.End)
                {
                    current = _allStream.Count - 1;
                }

                if (current < _allStream.Count - 1)
                {
                    var events = new RecordedEvent[_allStream.Count - current];
                    _allStream.CopyTo(events, current);
                    currentEvents = events;
                }
            }

            for (int i = 0; i < currentEvents.Length; i++)
            {
                eventAppeared(currentEvents[i]);
            }

            var subscription = new AllStreamSubscription(current, subscriptionDropped, eventAppeared);

            subscription.BusSubscription = _inboundEventBus.Subscribe(subscription);
            _subscriptions.Add(subscription);
            liveProcessingStarted?.Invoke();
            return(subscription);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public EventStoreHostedService(IEventStoreConnection connection, AllStreamSubscription subscription)
 {
     _connection   = connection;
     _subscription = subscription;
 }