From 7c52b1d43a046dc87e9e19d66447fe26feaf8db3 Mon Sep 17 00:00:00 2001 From: Arne Dumarey Date: Tue, 13 Feb 2024 11:40:30 +0100 Subject: [PATCH] fix: bump projection-handling + add configure awaits --- paket.dependencies | 12 +++++----- paket.lock | 24 +++++++++---------- .../Handlers/QueryHandler.cs | 2 +- .../ConnectedProjectionsCommandBus.cs | 2 +- .../Internal/ConnectedProjectionContext.cs | 22 ++++++++++------- .../DefaultCatchUpStreamGapStrategy.cs | 2 +- .../ProjectionsManagerHelpers.cs | 9 ++++--- 7 files changed, 40 insertions(+), 33 deletions(-) diff --git a/paket.dependencies b/paket.dependencies index 3c002b8..a01ea91 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -40,12 +40,12 @@ nuget Be.Vlaanderen.Basisregisters.Build.Pipeline 6.0.6 nuget Be.Vlaanderen.Basisregisters.DependencyInjection 1.0.3 -nuget Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner 12.1.2 -nuget Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner.Microsoft 12.1.2 -nuget Be.Vlaanderen.Basisregisters.ProjectionHandling.Connector 12.1.2 -nuget Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore 12.1.2 -nuget Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore.Autofac 12.1.2 -nuget Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore.Microsoft 12.1.2 +nuget Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner 12.1.3 +nuget Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner.Microsoft 12.1.3 +nuget Be.Vlaanderen.Basisregisters.ProjectionHandling.Connector 12.1.3 +nuget Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore 12.1.3 +nuget Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore.Autofac 12.1.3 +nuget Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore.Microsoft 12.1.3 nuget Be.Vlaanderen.Basisregisters.AggregateSource.SqlStreamStore.Autofac 7.1.3 nuget Be.Vlaanderen.Basisregisters.AggregateSource.SqlStreamStore.Microsoft 7.1.3 diff --git a/paket.lock b/paket.lock index 2056515..3bfeed6 100644 --- a/paket.lock +++ b/paket.lock @@ -81,13 +81,13 @@ NUGET Be.Vlaanderen.Basisregisters.EventHandling.Microsoft (4.2.2) Be.Vlaanderen.Basisregisters.DependencyInjection (>= 1.0.2) Be.Vlaanderen.Basisregisters.EventHandling (4.2.2) - Be.Vlaanderen.Basisregisters.ProjectionHandling.Connector (12.1.2) + Be.Vlaanderen.Basisregisters.ProjectionHandling.Connector (12.1.3) Microsoft.EntityFrameworkCore (>= 6.0.3) - Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner (12.1.2) + Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner (12.1.3) Autofac.Extensions.DependencyInjection (>= 7.2) Be.Vlaanderen.Basisregisters.EntityFrameworkCore.EntityTypeConfiguration (>= 3.0) - Be.Vlaanderen.Basisregisters.ProjectionHandling.Connector (12.1.2) - Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore (12.1.2) + Be.Vlaanderen.Basisregisters.ProjectionHandling.Connector (12.1.3) + Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore (12.1.3) Microsoft.EntityFrameworkCore.InMemory (>= 6.0.3) Microsoft.EntityFrameworkCore.Relational (>= 6.0.3) Microsoft.Extensions.Configuration (>= 6.0.1) @@ -96,11 +96,11 @@ NUGET Microsoft.Extensions.Configuration.FileExtensions (>= 6.0) Microsoft.Extensions.Configuration.Json (>= 6.0) SqlStreamStore (>= 1.2) - Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner.Microsoft (12.1.2) + Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner.Microsoft (12.1.3) Be.Vlaanderen.Basisregisters.DependencyInjection (>= 1.0.3) Be.Vlaanderen.Basisregisters.EntityFrameworkCore.EntityTypeConfiguration (>= 3.0) - Be.Vlaanderen.Basisregisters.ProjectionHandling.Connector (12.1.2) - Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore (12.1.2) + Be.Vlaanderen.Basisregisters.ProjectionHandling.Connector (12.1.3) + Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore (12.1.3) Microsoft.EntityFrameworkCore.InMemory (>= 6.0.3) Microsoft.EntityFrameworkCore.SqlServer (>= 6.0.3) Microsoft.Extensions.Configuration (>= 6.0.1) @@ -109,15 +109,15 @@ NUGET Microsoft.Extensions.Configuration.FileExtensions (>= 6.0) Microsoft.Extensions.Configuration.Json (>= 6.0) SqlStreamStore (>= 1.2) - Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore (12.1.2) + Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore (12.1.3) Be.Vlaanderen.Basisregisters.EventHandling (>= 4.2.2) SqlStreamStore (>= 1.2) - Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore.Autofac (12.1.2) + Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore.Autofac (12.1.3) Autofac.Extensions.DependencyInjection (>= 7.2) - Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore (12.1.2) - Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore.Microsoft (12.1.2) + Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore (12.1.3) + Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore.Microsoft (12.1.3) Be.Vlaanderen.Basisregisters.DependencyInjection (>= 1.0.3) - Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore (12.1.2) + Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore (12.1.3) Be.Vlaanderen.Basisregisters.Utilities.HashCodeCalculator (3.0) Be.Vlaanderen.Basisregisters.Utilities.HexByteConvertor (3.0) Be.Vlaanderen.Basisregisters.Utilities.ToStringBuilder (3.0) diff --git a/src/Be.Vlaanderen.Basisregisters.Projector/Handlers/QueryHandler.cs b/src/Be.Vlaanderen.Basisregisters.Projector/Handlers/QueryHandler.cs index baa81b5..fdc475a 100644 --- a/src/Be.Vlaanderen.Basisregisters.Projector/Handlers/QueryHandler.cs +++ b/src/Be.Vlaanderen.Basisregisters.Projector/Handlers/QueryHandler.cs @@ -64,7 +64,7 @@ public async Task> Handle(QueryRequest request) // execute sql try { - var result = await ExecuteQuery(request.ConnectionString, cmdText, param); + var result = await ExecuteQuery(request.ConnectionString, cmdText, param).ConfigureAwait(false); return Result.Success(result); } catch (SqlException ex) diff --git a/src/Be.Vlaanderen.Basisregisters.Projector/Internal/Commands/ConnectedProjectionsCommandBus.cs b/src/Be.Vlaanderen.Basisregisters.Projector/Internal/Commands/ConnectedProjectionsCommandBus.cs index 514de8d..283be84 100755 --- a/src/Be.Vlaanderen.Basisregisters.Projector/Internal/Commands/ConnectedProjectionsCommandBus.cs +++ b/src/Be.Vlaanderen.Basisregisters.Projector/Internal/Commands/ConnectedProjectionsCommandBus.cs @@ -35,6 +35,6 @@ public void Register(IConnectedProjectionsCommandHandler commandHandler) public void Queue(TCommand command) where TCommand : ConnectedProjectionCommand - => _mailbox.SendAsync(command); + => _mailbox.SendAsync(command).NoContext(); } } diff --git a/src/Be.Vlaanderen.Basisregisters.Projector/Internal/ConnectedProjectionContext.cs b/src/Be.Vlaanderen.Basisregisters.Projector/Internal/ConnectedProjectionContext.cs index ec484d4..6967400 100644 --- a/src/Be.Vlaanderen.Basisregisters.Projector/Internal/ConnectedProjectionContext.cs +++ b/src/Be.Vlaanderen.Basisregisters.Projector/Internal/ConnectedProjectionContext.cs @@ -71,7 +71,7 @@ public ConnectedProjectionContext( ConnectedProjectionIdentifier projection, CancellationToken cancellationToken) { - var state = await GetProjectionState(projection, cancellationToken); + var state = await GetProjectionState(projection, cancellationToken).ConfigureAwait(false); return state?.Position; } @@ -83,13 +83,14 @@ public async Task UpdateProjectionPosition( .UpdateProjectionState( projection.ToString(), position, - cancellationToken); + cancellationToken) + .ConfigureAwait(false); public async Task GetProjectionDesiredState( ConnectedProjectionIdentifier projection, CancellationToken cancellationToken) { - var projectionState = await GetProjectionState(projection, cancellationToken); + var projectionState = await GetProjectionState(projection, cancellationToken).ConfigureAwait(false); return UserDesiredState.TryParse(projectionState?.DesiredState ?? string.Empty, out var state) ? state : null; @@ -102,7 +103,8 @@ public async Task UpdateProjectionDesiredState( => await _context.UpdateProjectionDesiredState( projection, userDesiredState, - CancellationToken.None); + CancellationToken.None) + .ConfigureAwait(false); public async Task ApplyProjections( ConnectedProjector projector, @@ -111,7 +113,8 @@ public async Task ApplyProjections( => await projector.ProjectAsync( _context, _envelopeFactory.Create(message), - cancellationToken); + cancellationToken) + .ConfigureAwait(false); public async Task SetErrorMessage( ConnectedProjectionIdentifier projection, @@ -119,16 +122,16 @@ public async Task SetErrorMessage( CancellationToken cancellationToken) { //exception.ToString() => https://stackoverflow.com/a/2176722/412692 - await _context.SetErrorMessage(projection, exception.ToString(), cancellationToken); + await _context.SetErrorMessage(projection, exception.ToString(), cancellationToken).ConfigureAwait(false); } public async Task ClearErrorMessage( ConnectedProjectionIdentifier projection, CancellationToken cancellationToken) - => await _context.SetErrorMessage(projection, null, cancellationToken); + => await _context.SetErrorMessage(projection, null, cancellationToken).ConfigureAwait(false); public async Task SaveChangesAsync(CancellationToken cancellationToken) - => await _context.SaveChangesAsync(cancellationToken); + => await _context.SaveChangesAsync(cancellationToken).ConfigureAwait(false); public void Dispose() => _context.Dispose(); @@ -145,7 +148,8 @@ public ValueTask DisposeAsync() .AsNoTracking() .SingleOrDefaultAsync( item => item.Name == projection.ToString(), - cancellationToken); + cancellationToken) + .ConfigureAwait(false); } } } diff --git a/src/Be.Vlaanderen.Basisregisters.Projector/Internal/StreamGapStrategies/DefaultCatchUpStreamGapStrategy.cs b/src/Be.Vlaanderen.Basisregisters.Projector/Internal/StreamGapStrategies/DefaultCatchUpStreamGapStrategy.cs index b1f9ca7..c952a34 100644 --- a/src/Be.Vlaanderen.Basisregisters.Projector/Internal/StreamGapStrategies/DefaultCatchUpStreamGapStrategy.cs +++ b/src/Be.Vlaanderen.Basisregisters.Projector/Internal/StreamGapStrategies/DefaultCatchUpStreamGapStrategy.cs @@ -51,7 +51,7 @@ public async Task HandleMessage( private async Task IsCloseToStreamEnd(StreamMessage message, CancellationToken cancellationToken) { - var headPosition = await _streamStore.ReadHeadPosition(cancellationToken); + var headPosition = await _streamStore.ReadHeadPosition(cancellationToken).ConfigureAwait(false); var now = _clock .GetCurrentInstant() .ToDateTimeUtc(); diff --git a/src/Be.Vlaanderen.Basisregisters.Projector/ProjectionsManagerHelpers.cs b/src/Be.Vlaanderen.Basisregisters.Projector/ProjectionsManagerHelpers.cs index 8885ff0..ccabf5a 100755 --- a/src/Be.Vlaanderen.Basisregisters.Projector/ProjectionsManagerHelpers.cs +++ b/src/Be.Vlaanderen.Basisregisters.Projector/ProjectionsManagerHelpers.cs @@ -41,11 +41,14 @@ public static IApplicationBuilder UseProjectionsManagerAsync( { options.Common.ApplicationLifetime.ApplicationStopping.Register(() => ProjectionsCancellationTokenSource.Cancel()); - Task.Run(() => + Task.Run(async () => { var projectionsManager = options.Common.ServiceProvider.GetRequiredService(); - projectionsManager.Resume(ProjectionsCancellationTokenSource.Token); - }, ProjectionsCancellationTokenSource.Token).GetAwaiter().GetResult(); + await projectionsManager.Resume(ProjectionsCancellationTokenSource.Token).ConfigureAwait(false); + }, ProjectionsCancellationTokenSource.Token) + .ConfigureAwait(false) + .GetAwaiter() + .GetResult(); return app; }