コード例 #1
0
        public async Task Should_wakeup_when_already_subscribed()
        {
            await sut.OnActivateAsync(consumerName);

            await sut.ActivateAsync();

            await sut.ActivateAsync();

            A.CallTo(() => eventSubscription.WakeUp())
            .MustHaveHappened();
        }
コード例 #2
0
 private void Subscribe(string position)
 {
     if (currentSubscription == null)
     {
         currentSubscription?.StopAsync().Forget();
         currentSubscription = CreateSubscription(eventConsumer.EventsFilter, position);
     }
     else
     {
         currentSubscription.WakeUp();
     }
 }
コード例 #3
0
        private async Task <IReadOnlyList <StoredEvent> > QueryWithSubscriptionAsync(string streamFilter, Func <Task> action = null, bool fromBeginning = false)
        {
            var subscriber = new EventSubscriber();

            IEventSubscription subscription = null;

            try
            {
                subscription = Sut.CreateSubscription(subscriber, streamFilter, fromBeginning ? null : subscriptionPosition);

                if (action != null)
                {
                    await action();
                }

                using (var cts = new CancellationTokenSource(30000))
                {
                    while (!cts.IsCancellationRequested)
                    {
                        subscription.WakeUp();

                        await Task.Delay(500, cts.Token);

                        if (subscriber.Events.Count > 0)
                        {
                            subscriptionPosition = subscriber.LastPosition;

                            return(subscriber.Events);
                        }
                    }

                    cts.Token.ThrowIfCancellationRequested();

                    return(null);
                }
            }
            finally
            {
                await subscription.StopAsync();
            }
        }
コード例 #4
0
ファイル: BatchSubscriber.cs プロジェクト: Oceanswave/squidex
 public void WakeUp()
 {
     eventSubscription.WakeUp();
 }
コード例 #5
0
 public void WakeUp()
 {
     currentSubscription?.WakeUp();
 }