public async Task Should_wakeup_when_already_subscribed() { await sut.OnActivateAsync(consumerName); await sut.ActivateAsync(); await sut.ActivateAsync(); A.CallTo(() => eventSubscription.WakeUp()) .MustHaveHappened(); }
private void Subscribe(string position) { if (currentSubscription == null) { currentSubscription?.StopAsync().Forget(); currentSubscription = CreateSubscription(eventConsumer.EventsFilter, position); } else { currentSubscription.WakeUp(); } }
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(); } }
public void WakeUp() { eventSubscription.WakeUp(); }
public void WakeUp() { currentSubscription?.WakeUp(); }