Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aspire playground #3022

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 65 additions & 2 deletions Brighter.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
VisualStudioVersion = 17.8.0.0
MinimumVisualStudioVersion = 17.8.0.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{235DE1F1-E71B-4817-8E27-3B34FF006E4C}"
ProjectSection(SolutionItems) = preProject
samples\AspireSetup.md = samples\AspireSetup.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{329736D2-BF92-4D06-A7BF-19F4B6B64EDD}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -337,6 +340,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Paramore.Brighter.ServiceAc
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Paramore.Brighter.Sqlite.Dapper", "src\Paramore.Brighter.Sqlite.Dapper\Paramore.Brighter.Sqlite.Dapper.csproj", "{3384FBF0-5DCB-452D-8288-FAD1D0023089}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppHost", "samples\RMQTaskQueue\AppHost\AppHost.csproj", "{995A09D0-C440-4E88-A0C6-7AF93D82CA82}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceDefaults", "samples\RMQTaskQueue\ServiceDefaults\ServiceDefaults.csproj", "{69AF4ECC-FABB-431F-89CF-0AF972BF197F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI_EFCore.AppHost", "samples\WebAPI_EFCore\WebAPI_EFCore.AppHost\WebAPI_EFCore.AppHost.csproj", "{F457820A-6B15-4697-B2B3-E3E9FCAABFDE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebAPI_EFCore.ServiceDefaults", "samples\WebAPI_EFCore\WebAPI_EFCore.ServiceDefaults\WebAPI_EFCore.ServiceDefaults.csproj", "{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1931,6 +1942,54 @@ Global
{3384FBF0-5DCB-452D-8288-FAD1D0023089}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{3384FBF0-5DCB-452D-8288-FAD1D0023089}.Release|x86.ActiveCfg = Release|Any CPU
{3384FBF0-5DCB-452D-8288-FAD1D0023089}.Release|x86.Build.0 = Release|Any CPU
{995A09D0-C440-4E88-A0C6-7AF93D82CA82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{995A09D0-C440-4E88-A0C6-7AF93D82CA82}.Debug|Any CPU.Build.0 = Debug|Any CPU
{995A09D0-C440-4E88-A0C6-7AF93D82CA82}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{995A09D0-C440-4E88-A0C6-7AF93D82CA82}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{995A09D0-C440-4E88-A0C6-7AF93D82CA82}.Debug|x86.ActiveCfg = Debug|Any CPU
{995A09D0-C440-4E88-A0C6-7AF93D82CA82}.Debug|x86.Build.0 = Debug|Any CPU
{995A09D0-C440-4E88-A0C6-7AF93D82CA82}.Release|Any CPU.ActiveCfg = Release|Any CPU
{995A09D0-C440-4E88-A0C6-7AF93D82CA82}.Release|Any CPU.Build.0 = Release|Any CPU
{995A09D0-C440-4E88-A0C6-7AF93D82CA82}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{995A09D0-C440-4E88-A0C6-7AF93D82CA82}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{995A09D0-C440-4E88-A0C6-7AF93D82CA82}.Release|x86.ActiveCfg = Release|Any CPU
{995A09D0-C440-4E88-A0C6-7AF93D82CA82}.Release|x86.Build.0 = Release|Any CPU
{69AF4ECC-FABB-431F-89CF-0AF972BF197F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69AF4ECC-FABB-431F-89CF-0AF972BF197F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69AF4ECC-FABB-431F-89CF-0AF972BF197F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{69AF4ECC-FABB-431F-89CF-0AF972BF197F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{69AF4ECC-FABB-431F-89CF-0AF972BF197F}.Debug|x86.ActiveCfg = Debug|Any CPU
{69AF4ECC-FABB-431F-89CF-0AF972BF197F}.Debug|x86.Build.0 = Debug|Any CPU
{69AF4ECC-FABB-431F-89CF-0AF972BF197F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69AF4ECC-FABB-431F-89CF-0AF972BF197F}.Release|Any CPU.Build.0 = Release|Any CPU
{69AF4ECC-FABB-431F-89CF-0AF972BF197F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{69AF4ECC-FABB-431F-89CF-0AF972BF197F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{69AF4ECC-FABB-431F-89CF-0AF972BF197F}.Release|x86.ActiveCfg = Release|Any CPU
{69AF4ECC-FABB-431F-89CF-0AF972BF197F}.Release|x86.Build.0 = Release|Any CPU
{F457820A-6B15-4697-B2B3-E3E9FCAABFDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F457820A-6B15-4697-B2B3-E3E9FCAABFDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F457820A-6B15-4697-B2B3-E3E9FCAABFDE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{F457820A-6B15-4697-B2B3-E3E9FCAABFDE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{F457820A-6B15-4697-B2B3-E3E9FCAABFDE}.Debug|x86.ActiveCfg = Debug|Any CPU
{F457820A-6B15-4697-B2B3-E3E9FCAABFDE}.Debug|x86.Build.0 = Debug|Any CPU
{F457820A-6B15-4697-B2B3-E3E9FCAABFDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F457820A-6B15-4697-B2B3-E3E9FCAABFDE}.Release|Any CPU.Build.0 = Release|Any CPU
{F457820A-6B15-4697-B2B3-E3E9FCAABFDE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{F457820A-6B15-4697-B2B3-E3E9FCAABFDE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{F457820A-6B15-4697-B2B3-E3E9FCAABFDE}.Release|x86.ActiveCfg = Release|Any CPU
{F457820A-6B15-4697-B2B3-E3E9FCAABFDE}.Release|x86.Build.0 = Release|Any CPU
{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF}.Debug|x86.ActiveCfg = Debug|Any CPU
{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF}.Debug|x86.Build.0 = Debug|Any CPU
{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF}.Release|Any CPU.Build.0 = Release|Any CPU
{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF}.Release|x86.ActiveCfg = Release|Any CPU
{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2044,6 +2103,10 @@ Global
{D7361C21-AB4D-4E82-8094-FB86C2ED1800} = {65F8C2DE-0CB6-4102-8187-A247F1D5D3D7}
{18742337-075A-40D6-B67F-91F5894A50C3} = {65F8C2DE-0CB6-4102-8187-A247F1D5D3D7}
{AA2AA086-9B8A-4910-A793-E92B1E352351} = {329736D2-BF92-4D06-A7BF-19F4B6B64EDD}
{995A09D0-C440-4E88-A0C6-7AF93D82CA82} = {E9748DC0-6E72-4634-AF49-428F806E03B0}
{69AF4ECC-FABB-431F-89CF-0AF972BF197F} = {E9748DC0-6E72-4634-AF49-428F806E03B0}
{F457820A-6B15-4697-B2B3-E3E9FCAABFDE} = {C6B17EFD-4F05-4D45-AF3E-C4F3F790B994}
{0D35AAF9-54AE-43CB-8E29-D9605ECA5EDF} = {C6B17EFD-4F05-4D45-AF3E-C4F3F790B994}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8B7C7E31-2E32-4E0D-9426-BC9AF22E9F4C}
Expand Down
11 changes: 10 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Aspire.Hosting" Version="8.0.0-preview.3.24105.21" />
<PackageVersion Include="Aspire.RabbitMQ.Client" Version="8.0.0-preview.3.24105.21" />
<PackageVersion Include="AWSSDK.DynamoDBv2" Version="3.7.301.9" />
<PackageVersion Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.300" />
<PackageVersion Include="AWSSDK.S3" Version="3.7.305.24" />
Expand All @@ -27,6 +29,7 @@
<PackageVersion Include="FluentMigrator" Version="5.0.0" />
<PackageVersion Include="FluentMigrator.Runner" Version="5.0.0" />
<PackageVersion Include="MessagePack" Version="2.5.140" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.2" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.1.5" />
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.1" />
<PackageVersion Include="Microsoft.Data.Sqlite.Core" Version="8.0.1" />
Expand All @@ -38,8 +41,10 @@
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="8.1.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.0-preview.3.24105.21" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="MySqlConnector" Version="2.3.5" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
Expand All @@ -55,9 +60,13 @@
<PackageVersion Include="OpenTelemetry.Exporter.Console" Version="1.7.0" />
<PackageVersion Include="OpenTelemetry.Exporter.InMemory" Version="1.7.0" />
<PackageVersion Include="OpenTelemetry.Exporter.Jaeger" Version="1.5.1" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0-alpha.1" />
<PackageVersion Include="OpenTelemetry.Exporter.Zipkin" Version="1.7.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0-alpha.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.6.0-beta.2" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.6.0-beta.2" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.5.1" />
<PackageVersion Include="Paramore.Darker" Version="3.0.0" />
<PackageVersion Include="Paramore.Darker.AspNetCore" Version="3.0.0" />
<PackageVersion Include="Paramore.Darker.Policies" Version="3.0.0" />
Expand Down
44 changes: 44 additions & 0 deletions samples/AspireSetup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Aspire documentation
https://learn.microsoft.com/en-us/dotnet/aspire/

Visual Studio:
Visual Studio 2022 Preview version 17.9 or higher (Optional)

Rider:
plugin is https://plugins.jetbrains.com/plugin/23289--net-aspire


To install the aspire workload
```shell
dotnet workload update
dotnet workload install aspire
```
To check your workload
```shell
dotnet workload list
```
To update your workloads
```shell
dotnet workload update
```

Aspire template
```shell
dotnet new list aspire
```

Try the sample-starter in a new directory
```shell
mkdir TestAspire
cd TestAspire
dotnet new aspire-starter
dotnet run --project TestAspire.AppHost
```

To run sample from the commandline

```shell
dotnet run --project samples/RMQTaskQueue/AppHost
```


20 changes: 20 additions & 0 deletions samples/RMQTaskQueue/AppHost/AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GreetingsReceiverConsole\GreetingsReceiverConsole.csproj" />
<ProjectReference Include="..\GreetingsSender\GreetingsSender.csproj" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions samples/RMQTaskQueue/AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var builder = DistributedApplication.CreateBuilder(args);

var rabbit = builder.AddRabbitMQ("messaging");

var receiver = builder.AddProject<Projects.GreetingsReceiverConsole>("receiver")
.WithReference(rabbit);
var sender = builder.AddProject<Projects.GreetingsSender>("sender")
.WithReference(rabbit);

builder.Build().Run();
16 changes: 16 additions & 0 deletions samples/RMQTaskQueue/AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15281",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16176"
}
}
}
}
8 changes: 8 additions & 0 deletions samples/RMQTaskQueue/AppHost/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions samples/RMQTaskQueue/AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Greetings\Greetings.csproj" />
<ProjectReference Include="..\ServiceDefaults\ServiceDefaults.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Aspire.RabbitMQ.Client" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
Expand Down
90 changes: 48 additions & 42 deletions samples/RMQTaskQueue/GreetingsReceiverConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ THE SOFTWARE. */

#endregion

using Aspire.RabbitMQ.Client;
using System;
using System.Threading.Tasks;
using Greetings.Ports.Commands;
Expand All @@ -32,6 +33,7 @@ THE SOFTWARE. */
using Paramore.Brighter.MessagingGateway.RMQ;
using Paramore.Brighter.ServiceActivator.Extensions.DependencyInjection;
using Paramore.Brighter.ServiceActivator.Extensions.Hosting;
using RabbitMQ.Client;
using Serilog;

namespace GreetingsReceiverConsole
Expand All @@ -46,52 +48,56 @@ public static async Task Main(string[] args)
.WriteTo.Console()
.CreateLogger();

var host = new HostBuilder()
.ConfigureServices((hostContext, services) =>
var subscriptions = new Subscription[]
{
new RmqSubscription<GreetingEvent>(
new SubscriptionName("paramore.example.greeting"),
new ChannelName("greeting.event"),
new RoutingKey("greeting.event"),
timeoutInMilliseconds: 200,
isDurable: true,
highAvailability: true,
makeChannels: OnMissingChannel
.Create), //change to OnMissingChannel.Validate if you have infrastructure declared elsewhere
new RmqSubscription<FarewellEvent>(
new SubscriptionName(
"paramore.example.farewell"), //change to OnMissingChannel.Validate if you have infrastructure declared elsewhere
new ChannelName("farewell.event"),
new RoutingKey("farewell.event"),
timeoutInMilliseconds: 200,
isDurable: true,
highAvailability: true,
makeChannels: OnMissingChannel.Create)
};

var builder = new HostApplicationBuilder();


builder.AddServiceDefaults();
builder.AddRabbitMQ("messaging");
builder.Logging.AddSerilog();

var rmqConnection = new RmqMessagingGatewayConnection
{
AmpqUri = new AmqpUriSpecification(builder.Services.BuildServiceProvider()
.GetService<IConnectionFactory>().Uri),
Exchange = new Exchange("paramore.brighter.exchange")
};

var rmqMessageConsumerFactory = new RmqMessageConsumerFactory(rmqConnection);

builder.Services.AddServiceActivator(options =>
{
var subscriptions = new Subscription[]
{
new RmqSubscription<GreetingEvent>(
new SubscriptionName("paramore.example.greeting"),
new ChannelName("greeting.event"),
new RoutingKey("greeting.event"),
timeoutInMilliseconds: 200,
isDurable: true,
highAvailability: true,
makeChannels: OnMissingChannel.Create), //change to OnMissingChannel.Validate if you have infrastructure declared elsewhere
new RmqSubscription<FarewellEvent>(
new SubscriptionName("paramore.example.farewell"), //change to OnMissingChannel.Validate if you have infrastructure declared elsewhere
new ChannelName("farewell.event"),
new RoutingKey("farewell.event"),
timeoutInMilliseconds: 200,
isDurable: true,
highAvailability: true,
makeChannels: OnMissingChannel.Create)
};

var rmqConnection = new RmqMessagingGatewayConnection
{
AmpqUri = new AmqpUriSpecification(new Uri("amqp://guest:guest@localhost:5672")),
Exchange = new Exchange("paramore.brighter.exchange")
};

var rmqMessageConsumerFactory = new RmqMessageConsumerFactory(rmqConnection);

services.AddServiceActivator(options =>
{
options.Subscriptions = subscriptions;
options.ChannelFactory = new ChannelFactory(rmqMessageConsumerFactory);
})
.AutoFromAssemblies();


services.AddHostedService<ServiceActivatorHostedService>();
options.Subscriptions = subscriptions;
options.ChannelFactory = new ChannelFactory(rmqMessageConsumerFactory);


})
.UseConsoleLifetime()
.UseSerilog()
.Build();
.AutoFromAssemblies();

builder.Services.AddHostedService<ServiceActivatorHostedService>();

using var host = builder.Build();
await host.RunAsync();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"GreetingsReceiverConsole": {
"commandName": "Project",
"dotnetRunMessages": true,
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
}
}
}
Loading
Loading