Skip to content

Commit

Permalink
fix: bump projection-handling + add configure awaits
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneD committed Feb 13, 2024
1 parent 677cd8c commit 7c52b1d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 33 deletions.
12 changes: 6 additions & 6 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task<Result<object>> Handle(QueryRequest request)
// execute sql
try
{
var result = await ExecuteQuery<dynamic>(request.ConnectionString, cmdText, param);
var result = await ExecuteQuery<dynamic>(request.ConnectionString, cmdText, param).ConfigureAwait(false);
return Result<dynamic>.Success(result);
}
catch (SqlException ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public void Register(IConnectedProjectionsCommandHandler commandHandler)

public void Queue<TCommand>(TCommand command)
where TCommand : ConnectedProjectionCommand
=> _mailbox.SendAsync(command);
=> _mailbox.SendAsync(command).NoContext();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -83,13 +83,14 @@ public async Task UpdateProjectionPosition(
.UpdateProjectionState(
projection.ToString(),
position,
cancellationToken);
cancellationToken)
.ConfigureAwait(false);

public async Task<UserDesiredState?> 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;
Expand All @@ -102,7 +103,8 @@ public async Task UpdateProjectionDesiredState(
=> await _context.UpdateProjectionDesiredState(
projection,
userDesiredState,
CancellationToken.None);
CancellationToken.None)
.ConfigureAwait(false);

public async Task ApplyProjections(
ConnectedProjector<TContext> projector,
Expand All @@ -111,24 +113,25 @@ public async Task ApplyProjections(
=> await projector.ProjectAsync(
_context,
_envelopeFactory.Create(message),
cancellationToken);
cancellationToken)
.ConfigureAwait(false);

public async Task SetErrorMessage(
ConnectedProjectionIdentifier projection,
Exception exception,
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();
Expand All @@ -145,7 +148,8 @@ public ValueTask DisposeAsync()
.AsNoTracking()
.SingleOrDefaultAsync(
item => item.Name == projection.ToString(),
cancellationToken);
cancellationToken)
.ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task HandleMessage(

private async Task<bool> IsCloseToStreamEnd(StreamMessage message, CancellationToken cancellationToken)
{
var headPosition = await _streamStore.ReadHeadPosition(cancellationToken);
var headPosition = await _streamStore.ReadHeadPosition(cancellationToken).ConfigureAwait(false);
var now = _clock
.GetCurrentInstant()
.ToDateTimeUtc();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IConnectedProjectionsManager>();
projectionsManager.Resume(ProjectionsCancellationTokenSource.Token);
}, ProjectionsCancellationTokenSource.Token).GetAwaiter().GetResult();
await projectionsManager.Resume(ProjectionsCancellationTokenSource.Token).ConfigureAwait(false);
}, ProjectionsCancellationTokenSource.Token)
.ConfigureAwait(false)
.GetAwaiter()
.GetResult();

return app;
}
Expand Down

0 comments on commit 7c52b1d

Please sign in to comment.