Skip to content

Commit

Permalink
Upgrade to .NET Aspire 9
Browse files Browse the repository at this point in the history
  • Loading branch information
fredimachado committed Nov 14, 2024
1 parent 96f29a0 commit cb1e404
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 72 deletions.
58 changes: 29 additions & 29 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,45 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Aspirant.Hosting" Version="0.0.3" />
<PackageVersion Include="Aspire.Hosting" Version="8.0.1" />
<PackageVersion Include="Aspire.Hosting.AppHost" Version="8.0.1" />
<PackageVersion Include="Aspire.Hosting.RabbitMQ" Version="8.0.1" />
<PackageVersion Include="Aspire.RabbitMQ.Client" Version="8.0.1" />
<PackageVersion Include="Aspire.Hosting" Version="9.0.0" />
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.0.0" />
<PackageVersion Include="Aspire.Hosting.RabbitMQ" Version="9.0.0" />
<PackageVersion Include="Aspire.RabbitMQ.Client" Version="9.0.0" />
<PackageVersion Include="AspNetCore.HealthChecks.EventStore.gRPC" Version="6.0.1" />
<PackageVersion Include="AspNetCore.HealthChecks.Rabbitmq" Version="8.0.1" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.3.3" />
<PackageVersion Include="MediatR" Version="12.2.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.5" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="8.5.0" />
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="8.5.0" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.1" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.8.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.1" />
<PackageVersion Include="AspNetCore.HealthChecks.Rabbitmq" Version="8.0.2" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageVersion Include="MediatR" Version="12.4.1" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.11" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="8.10.0" />
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="8.2.2" />
<PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="8.10.0" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.10.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.10.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0" />
<PackageVersion Include="AntDesign" Version="0.19.0" />
<PackageVersion Include="Ardalis.GuardClauses" Version="4.5.0" />
<PackageVersion Include="Ardalis.GuardClauses" Version="5.0.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" />
<PackageVersion Include="EventStore.Client.Grpc.Streams" Version="21.2.0" />
<PackageVersion Include="FakeItEasy" Version="8.2.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="FluentAssertions.Analyzers" Version="0.32.0" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.5" />
<PackageVersion Include="FakeItEasy" Version="8.3.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.2" />
<PackageVersion Include="FluentAssertions.Analyzers" Version="0.34.1" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.11" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.11" />
<PackageVersion Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.11" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="MinVer" Version="5.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="MinVer" Version="6.0.0" />
<PackageVersion Include="NetArchTest.Rules" Version="1.3.2" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="ReflectionMagic" Version="5.0.1" />
<PackageVersion Include="Scrutor" Version="4.2.2" />
<PackageVersion Include="Shouldly" Version="4.2.1" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageVersion Include="TngTech.ArchUnitNET.xUnit" Version="0.10.6" />
<PackageVersion Include="xunit" Version="2.8.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.1" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="7.0.0" />
<PackageVersion Include="TngTech.ArchUnitNET.xUnit" Version="0.11.1" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<ItemGroup>
<PackageReference Include="Aspire.Hosting" />
<PackageReference Include="AspNetCore.HealthChecks.EventStore.gRPC" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Aspire.Hosting.ApplicationModel;
using Aspire.Hosting.EventStore;
using HealthChecks.EventStore.gRPC;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;

namespace Aspire.Hosting;

Expand All @@ -17,15 +20,35 @@ public static class EventStoreBuilderExtensions
public static IResourceBuilder<EventStoreResource> AddEventStore(
this IDistributedApplicationBuilder builder, string name, int? httpPort = null, int? tcpPort = null)
{
var eventStoreContainer = new EventStoreResource(name);
var eventStoreResource = new EventStoreResource(name);

string? connectionString = null;

builder.Eventing.Subscribe<ConnectionStringAvailableEvent>(eventStoreResource, async (@event, cancellationToken) =>
{
connectionString = await eventStoreResource.ConnectionStringExpression
.GetValueAsync(cancellationToken)
.ConfigureAwait(false)
?? throw new DistributedApplicationException($"ConnectionStringAvailableEvent was published for the '{eventStoreResource.Name}' resource but the connection string was null.");
});

var healthCheckKey = $"{name}_check";
builder.Services.AddHealthChecks()
.Add(new HealthCheckRegistration(
healthCheckKey,
sp => new EventStoreHealthCheck(connectionString!),
failureStatus: default,
tags: default,
timeout: default));

return builder
.AddResource(eventStoreContainer)
.AddResource(eventStoreResource)
.WithEndpoint(port: tcpPort, targetPort: EventStoreResource.DefaultTcpPort, name: EventStoreResource.TcpEndpointName)
.WithHttpEndpoint(port: httpPort, targetPort: EventStoreResource.DefaultHttpPort, name: EventStoreResource.HttpEndpointName)
.WithImage(EventStoreContainerImageTags.Image, EventStoreContainerImageTags.Tag)
.WithImageRegistry(EventStoreContainerImageTags.Registry)
.WithEnvironment(ConfigureEventStoreContainer);
.WithEnvironment(ConfigureEventStoreContainer)
.WithHealthCheck(healthCheckKey);
}

/// <summary>
Expand Down

This file was deleted.

This file was deleted.

7 changes: 3 additions & 4 deletions src/Aspire/NCafe.AppHost/NCafe.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" />

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -9,11 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspirant.Hosting" />
<PackageReference Include="Aspire.Hosting.AppHost" />
<PackageReference Include="Aspire.Hosting.RabbitMQ" />
<PackageReference Include="AspNetCore.HealthChecks.EventStore.gRPC" />
<PackageReference Include="AspNetCore.HealthChecks.Rabbitmq" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 0 additions & 4 deletions src/Aspire/NCafe.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
using Aspirant.Hosting;

var builder = DistributedApplication.CreateBuilder(args);

var eventStore = builder.AddEventStore("eventstore")
.WithHealthCheck()
.WithDataVolume();

var rabbitMq = builder.AddRabbitMQ("rabbitmq")
.WithDataVolume()
.WithHealthCheck()
.WithManagementPlugin();

builder.AddProject<Projects.NCafe_Admin_Api>("admin-api")
Expand Down

0 comments on commit cb1e404

Please sign in to comment.