Browse Source

Cancellation token to the end of the method signature.

pull/221/head
Sebastian Stehle 8 years ago
parent
commit
bc0a4c3e58
  1. 2
      src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStore.cs
  2. 2
      src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs
  3. 2
      src/Squidex.Infrastructure/EventSourcing/IEventStore.cs
  4. 2
      src/Squidex.Infrastructure/EventSourcing/PollingSubscription.cs
  5. 12
      tests/Squidex.Infrastructure.Tests/EventSourcing/PollingSubscriptionTests.cs
  6. 6
      tools/Migrate_01/Rebuilder.cs

2
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<StoredEvent, Task> callback, CancellationToken cancellationToken, string streamFilter = null, string position = null)
public async Task GetEventsAsync(Func<StoredEvent, Task> callback, string streamFilter = null, string position = null, CancellationToken cancellationToken = default(CancellationToken))
{
var streamName = await connection.CreateProjectionAsync(projectionsManager, prefix, streamFilter);

2
src/Squidex.Infrastructure.MongoDb/EventSourcing/MongoEventStore.cs

@ -94,7 +94,7 @@ namespace Squidex.Infrastructure.EventSourcing
return result;
}
public async Task GetEventsAsync(Func<StoredEvent, Task> callback, CancellationToken cancellationToken, string streamFilter = null, string position = null)
public async Task GetEventsAsync(Func<StoredEvent, Task> callback, string streamFilter = null, string position = null, CancellationToken cancellationToken = default(CancellationToken))
{
Guard.NotNull(callback, nameof(callback));

2
src/Squidex.Infrastructure/EventSourcing/IEventStore.cs

@ -16,7 +16,7 @@ namespace Squidex.Infrastructure.EventSourcing
{
Task<IReadOnlyList<StoredEvent>> GetEventsAsync(string streamName, long streamPosition = 0);
Task GetEventsAsync(Func<StoredEvent, Task> callback, CancellationToken cancellationToken, string streamFilter = null, string position = null);
Task GetEventsAsync(Func<StoredEvent, Task> callback, string streamFilter = null, string position = null, CancellationToken cancellationToken = default(CancellationToken));
Task AppendEventsAsync(Guid commitId, string streamName, ICollection<EventData> events);

2
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)
{

12
tests/Squidex.Infrastructure.Tests/EventSourcing/PollingSubscriptionTests.cs

@ -27,7 +27,7 @@ namespace Squidex.Infrastructure.EventSourcing
await WaitAndStopAsync(sut);
A.CallTo(() => eventStore.GetEventsAsync(A<Func<StoredEvent, Task>>.Ignored, A<CancellationToken>.Ignored, "^my-stream", position))
A.CallTo(() => eventStore.GetEventsAsync(A<Func<StoredEvent, Task>>.Ignored, "^my-stream", position, A<CancellationToken>.Ignored))
.MustHaveHappened(Repeated.Exactly.Once);
}
@ -36,7 +36,7 @@ namespace Squidex.Infrastructure.EventSourcing
{
var ex = new InvalidOperationException();
A.CallTo(() => eventStore.GetEventsAsync(A<Func<StoredEvent, Task>>.Ignored, A<CancellationToken>.Ignored, "^my-stream", position))
A.CallTo(() => eventStore.GetEventsAsync(A<Func<StoredEvent, Task>>.Ignored, "^my-stream", position, A<CancellationToken>.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<Func<StoredEvent, Task>>.Ignored, A<CancellationToken>.Ignored, "^my-stream", position))
A.CallTo(() => eventStore.GetEventsAsync(A<Func<StoredEvent, Task>>.Ignored, "^my-stream", position, A<CancellationToken>.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<Func<StoredEvent, Task>>.Ignored, A<CancellationToken>.Ignored, "^my-stream", position))
A.CallTo(() => eventStore.GetEventsAsync(A<Func<StoredEvent, Task>>.Ignored, "^my-stream", position, A<CancellationToken>.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<Func<StoredEvent, Task>>.Ignored, A<CancellationToken>.Ignored, "^my-stream", position))
A.CallTo(() => eventStore.GetEventsAsync(A<Func<StoredEvent, Task>>.Ignored, "^my-stream", position, A<CancellationToken>.Ignored))
.MustHaveHappened(Repeated.Exactly.Once);
}
@ -101,7 +101,7 @@ namespace Squidex.Infrastructure.EventSourcing
await WaitAndStopAsync(sut);
A.CallTo(() => eventStore.GetEventsAsync(A<Func<StoredEvent, Task>>.Ignored, A<CancellationToken>.Ignored, "^my-stream", position))
A.CallTo(() => eventStore.GetEventsAsync(A<Func<StoredEvent, Task>>.Ignored, "^my-stream", position, A<CancellationToken>.Ignored))
.MustHaveHappened(Repeated.Exactly.Twice);
}

6
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<IEvent> ParseKnownEvent(StoredEvent storedEvent)

Loading…
Cancel
Save