public async Task OnError_Continue_prevents_aggregator_exceptions_from_stopping_catchup() { var projectionStore = new InMemoryProjectionStore <BalanceProjection>(); var count = 0; var projector = new BalanceProjector() .Pipeline(async(projection, batch, next) => { Interlocked.Increment(ref count); Console.WriteLine(count); if (count < 49) { Throw(); } await next(projection, batch); }).Trace(); var catchup = StreamCatchup.Create(stream.Trace(), batchSize: 50); catchup.Subscribe(projector, projectionStore.AsHandler(), onError: e => e.Continue()); await catchup.RunUntilCaughtUp(); projectionStore.Count().Should().Be(1); projectionStore.Single().CursorPosition.Should().Be(1); }
public async Task Catchup_batch_size_can_be_specified() { var projectionStore = new InMemoryProjectionStore<BalanceProjection>(); store.WriteEvents(streamId, howMany: 50); var catchup = StreamCatchup.Create(stream, batchCount: 20); catchup.Subscribe(new BalanceProjector(), projectionStore); await catchup.RunSingleBatch(); projectionStore.Single() .Balance .Should() .Be(20); }
public async Task Catchup_batch_size_can_be_specified() { var projectionStore = new InMemoryProjectionStore <BalanceProjection>(); store.WriteEvents(streamId, howMany: 50); var catchup = StreamCatchup.Create(stream, batchSize: 20); catchup.Subscribe(new BalanceProjector(), projectionStore); await catchup.RunSingleBatch(); projectionStore.Single() .Balance .Should() .Be(20); }
public async Task Catchup_RunUntilCaughtUp_runs_until_the_stream_has_no_more_results() { var projectionStore = new InMemoryProjectionStore <BalanceProjection>(); store.WriteEvents(streamId, howMany: 999); var catchup = StreamCatchup.Create(stream, batchSize: 10); catchup.Subscribe(new BalanceProjector(), projectionStore); TaskScheduler.UnobservedTaskException += (sender, args) => Console.WriteLine(args.Exception); await catchup.RunUntilCaughtUp(); projectionStore.Single() .Balance .Should() .Be(1000); }
public async Task OnError_Continue_prevents_aggregator_exceptions_from_stopping_catchup() { var projectionStore = new InMemoryProjectionStore<BalanceProjection>(); var count = 0; var projector = new BalanceProjector() .Pipeline(async (projection, batch, next) => { Interlocked.Increment(ref count); Console.WriteLine(count); if (count < 49) { Throw(); } await next(projection, batch); }).Trace(); var catchup = StreamCatchup.Create(stream.Trace(), batchCount: 50); catchup.Subscribe(projector, projectionStore.AsHandler(), onError: e => e.Continue()); await catchup.RunUntilCaughtUp(); projectionStore.Count().Should().Be(1); projectionStore.Single().CursorPosition.Should().Be(1); }
public async Task Catchup_RunUntilCaughtUp_runs_until_the_stream_has_no_more_results() { var projectionStore = new InMemoryProjectionStore<BalanceProjection>(); store.WriteEvents(streamId, howMany: 999); var catchup = StreamCatchup.Create(stream, batchCount: 10); catchup.Subscribe(new BalanceProjector(), projectionStore); TaskScheduler.UnobservedTaskException += (sender, args) => Console.WriteLine(args.Exception); await catchup.RunUntilCaughtUp(); projectionStore.Single() .Balance .Should() .Be(1000); }