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 RunSingleBatch_throws_when_an_aggregator_throws_an_exception() { var projectionStore = new InMemoryProjectionStore <BalanceProjection>(); store.WriteEvents(streamId, 100); var projector = new BalanceProjector() .Pipeline(async(projection, batch, next) => { Throw(); await next(projection, batch); }); var catchup = StreamCatchup.Create(stream, batchSize: 50); catchup.Subscribe(projector, projectionStore); Action runSingleBatch = () => catchup.RunSingleBatch().Wait(); runSingleBatch.ShouldThrow <Exception>() .And .Message .Should() .Contain("oops"); }
public async Task OnError_Continue_prevents_aggregator_exceptions_from_stopping_catchup() { var count = 0; var projectionStore = new InMemoryProjectionStore <BalanceProjection>(); var projector = new BalanceProjector() .Pipeline(async(projection, batch, next) => { Interlocked.Increment(ref count); if (count < 20) { throw new Exception("oops"); } await next(projection, batch); }).Trace(); var catchup = StreamCatchup.All(streamSource.StreamPerAggregate().Trace(), batchSize: 50); catchup.Subscribe(projector, projectionStore.AsHandler(), onError: e => e.Continue()); await catchup.RunSingleBatch(); projectionStore.Count().Should().Be(31); }
public async Task RunSingleBatch_throws_when_an_aggregator_throws_an_exception() { var projectionStore = new InMemoryProjectionStore <BalanceProjection>(); var projector = new BalanceProjector() .Pipeline(async(projection, batch, next) => { if (projectionStore.Count() >= 30) { throw new Exception("oops"); } await next(projection, batch); }); var catchup = StreamCatchup.All(streamSource.StreamPerAggregate(), batchSize: 50); catchup.Subscribe(projector, projectionStore); Action runSingleBatch = () => catchup.RunSingleBatch().Wait(); runSingleBatch.ShouldThrow <Exception>() .And .Message .Should() .Contain("oops"); }
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 RunSingleBatch_throws_when_an_aggregator_throws_an_exception() { var projectionStore = new InMemoryProjectionStore<BalanceProjection>(); store.WriteEvents(streamId, 100); var projector = new BalanceProjector() .Pipeline(async (projection, batch, next) => { Throw(); await next(projection, batch); }); var catchup = StreamCatchup.Create(stream, batchCount: 50); catchup.Subscribe(projector, projectionStore); Action runSingleBatch = () => catchup.RunSingleBatch().Wait(); runSingleBatch.ShouldThrow<Exception>() .And .Message .Should() .Contain("oops"); }
public async Task OnError_Continue_prevents_aggregator_exceptions_from_stopping_catchup() { var count = 0; var projectionStore = new InMemoryProjectionStore<BalanceProjection>(); var projector = new BalanceProjector() .Pipeline(async (projection, batch, next) => { Interlocked.Increment(ref count); if (count < 20) { throw new Exception("oops"); } await next(projection, batch); }).Trace(); var catchup = StreamCatchup.All(streamSource.StreamPerAggregate().Trace(), batchSize: 50); catchup.Subscribe(projector, projectionStore.AsHandler(), onError: e => e.Continue()); await catchup.RunSingleBatch(); projectionStore.Count().Should().Be(31); }
public async Task RunSingleBatch_throws_when_an_aggregator_throws_an_exception() { var projectionStore = new InMemoryProjectionStore<BalanceProjection>(); var projector = new BalanceProjector() .Pipeline(async (projection, batch, next) => { if (projectionStore.Count() >= 30) { throw new Exception("oops"); } await next(projection, batch); }); var catchup = StreamCatchup.All(streamSource.StreamPerAggregate(), batchSize: 50); catchup.Subscribe(projector, projectionStore); Action runSingleBatch = () => catchup.RunSingleBatch().Wait(); runSingleBatch.ShouldThrow<Exception>() .And .Message .Should() .Contain("oops"); }