From bc0a4c3e580a3c48c963070307e5a4b575450f5a Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Thu, 11 Jan 2018 18:08:39 +0100 Subject: [PATCH] Cancellation token to the end of the method signature. --- .../EventSourcing/GetEventStore.cs | 2 +- .../EventSourcing/MongoEventStore.cs | 2 +- .../EventSourcing/IEventStore.cs | 2 +- .../EventSourcing/PollingSubscription.cs | 2 +- .../EventSourcing/PollingSubscriptionTests.cs | 12 ++++++------ tools/Migrate_01/Rebuilder.cs | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs b/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs index f21319bc4..2023d0f73 100644 --- a/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs +++ b/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs @@ -62,7 +62,7 @@ namespace Squidex.Infrastructure.EventSourcing return new GetEventStoreSubscription(connection, subscriber, projectionsManager, prefix, position, streamFilter); } - public async Task GetEventsAsync(Func callback, CancellationToken cancellationToken, string streamFilter = null, string position = null) + public async Task GetEventsAsync(Func callback, string streamFilter = null, string position = null, CancellationToken cancellationToken = default(CancellationToken)) { var streamName = await connection.CreateProjectionAsync(projectionsManager, prefix, streamFilter); diff --git a/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs b/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs index f8fe15c59..2b4c072a3 100644 --- a/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs +++ b/src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs @@ -94,7 +94,7 @@ namespace Squidex.Infrastructure.EventSourcing return result; } - public async Task GetEventsAsync(Func callback, CancellationToken cancellationToken, string streamFilter = null, string position = null) + public async Task GetEventsAsync(Func callback, string streamFilter = null, string position = null, CancellationToken cancellationToken = default(CancellationToken)) { Guard.NotNull(callback, nameof(callback)); diff --git a/src/Squidex.Infrastructure/EventSourcing/IEventStore.cs b/src/Squidex.Infrastructure/EventSourcing/IEventStore.cs index 9a3e0d197..2993ef86b 100644 --- a/src/Squidex.Infrastructure/EventSourcing/IEventStore.cs +++ b/src/Squidex.Infrastructure/EventSourcing/IEventStore.cs @@ -16,7 +16,7 @@ namespace Squidex.Infrastructure.EventSourcing { Task> GetEventsAsync(string streamName, long streamPosition = 0); - Task GetEventsAsync(Func callback, CancellationToken cancellationToken, string streamFilter = null, string position = null); + Task GetEventsAsync(Func callback, string streamFilter = null, string position = null, CancellationToken cancellationToken = default(CancellationToken)); Task AppendEventsAsync(Guid commitId, string streamName, ICollection events); diff --git a/src/Squidex.Infrastructure/EventSourcing/PollingSubscription.cs b/src/Squidex.Infrastructure/EventSourcing/PollingSubscription.cs index cc6ed750f..dd5fc072b 100644 --- a/src/Squidex.Infrastructure/EventSourcing/PollingSubscription.cs +++ b/src/Squidex.Infrastructure/EventSourcing/PollingSubscription.cs @@ -51,7 +51,7 @@ namespace Squidex.Infrastructure.EventSourcing await eventSubscriber.OnEventAsync(this, storedEvent); position = storedEvent.EventPosition; - }, ct, streamFilter, position); + }, streamFilter, position, ct); } catch (Exception ex) { diff --git a/tests/Squidex.Infrastructure.Tests/EventSourcing/PollingSubscriptionTests.cs b/tests/Squidex.Infrastructure.Tests/EventSourcing/PollingSubscriptionTests.cs index 94fbbafbb..4c58d2655 100644 --- a/tests/Squidex.Infrastructure.Tests/EventSourcing/PollingSubscriptionTests.cs +++ b/tests/Squidex.Infrastructure.Tests/EventSourcing/PollingSubscriptionTests.cs @@ -27,7 +27,7 @@ namespace Squidex.Infrastructure.EventSourcing await WaitAndStopAsync(sut); - A.CallTo(() => eventStore.GetEventsAsync(A>.Ignored, A.Ignored, "^my-stream", position)) + A.CallTo(() => eventStore.GetEventsAsync(A>.Ignored, "^my-stream", position, A.Ignored)) .MustHaveHappened(Repeated.Exactly.Once); } @@ -36,7 +36,7 @@ namespace Squidex.Infrastructure.EventSourcing { var ex = new InvalidOperationException(); - A.CallTo(() => eventStore.GetEventsAsync(A>.Ignored, A.Ignored, "^my-stream", position)) + A.CallTo(() => eventStore.GetEventsAsync(A>.Ignored, "^my-stream", position, A.Ignored)) .Throws(ex); var sut = new PollingSubscription(eventStore, eventNotifier, eventSubscriber, "^my-stream", position); @@ -52,7 +52,7 @@ namespace Squidex.Infrastructure.EventSourcing { var ex = new OperationCanceledException(); - A.CallTo(() => eventStore.GetEventsAsync(A>.Ignored, A.Ignored, "^my-stream", position)) + A.CallTo(() => eventStore.GetEventsAsync(A>.Ignored, "^my-stream", position, A.Ignored)) .Throws(ex); var sut = new PollingSubscription(eventStore, eventNotifier, eventSubscriber, "^my-stream", position); @@ -68,7 +68,7 @@ namespace Squidex.Infrastructure.EventSourcing { var ex = new AggregateException(new OperationCanceledException()); - A.CallTo(() => eventStore.GetEventsAsync(A>.Ignored, A.Ignored, "^my-stream", position)) + A.CallTo(() => eventStore.GetEventsAsync(A>.Ignored, "^my-stream", position, A.Ignored)) .Throws(ex); var sut = new PollingSubscription(eventStore, eventNotifier, eventSubscriber, "^my-stream", position); @@ -88,7 +88,7 @@ namespace Squidex.Infrastructure.EventSourcing await WaitAndStopAsync(sut); - A.CallTo(() => eventStore.GetEventsAsync(A>.Ignored, A.Ignored, "^my-stream", position)) + A.CallTo(() => eventStore.GetEventsAsync(A>.Ignored, "^my-stream", position, A.Ignored)) .MustHaveHappened(Repeated.Exactly.Once); } @@ -101,7 +101,7 @@ namespace Squidex.Infrastructure.EventSourcing await WaitAndStopAsync(sut); - A.CallTo(() => eventStore.GetEventsAsync(A>.Ignored, A.Ignored, "^my-stream", position)) + A.CallTo(() => eventStore.GetEventsAsync(A>.Ignored, "^my-stream", position, A.Ignored)) .MustHaveHappened(Repeated.Exactly.Twice); } diff --git a/tools/Migrate_01/Rebuilder.cs b/tools/Migrate_01/Rebuilder.cs index af7014350..a401c39d7 100644 --- a/tools/Migrate_01/Rebuilder.cs +++ b/tools/Migrate_01/Rebuilder.cs @@ -68,7 +68,7 @@ namespace Migrate_01 await asset.WriteSnapshotAsync(); } } - }, CancellationToken.None, filter); + }, filter, cancellationToken: CancellationToken.None); } public Task RebuildConfigAsync() @@ -102,7 +102,7 @@ namespace Migrate_01 await app.WriteSnapshotAsync(); } } - }, CancellationToken.None, filter); + }, filter, cancellationToken: CancellationToken.None); } public async Task RebuildContentAsync() @@ -139,7 +139,7 @@ namespace Migrate_01 // Schema has been deleted. } } - }, CancellationToken.None, filter); + }, filter, cancellationToken: CancellationToken.None); } private Envelope ParseKnownEvent(StoredEvent storedEvent)