-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Update src/CommunityToolkit.Aspire.Hosting.LavinMQ/LavinMQHostingExtension.cs refactor: remove connection string builder. Co-authored-by: Aaron Powell <[email protected]>
- Loading branch information
1 parent
60172d0
commit 6b47e96
Showing
28 changed files
with
765 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...kit.Aspire.Hosting.LavinMQ.AppHost/CommunityToolkit.Aspire.Hosting.LavinMQ.AppHost.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<Sdk Name="Aspire.AppHost.Sdk" Version="$(AspireAppHostSdkVersion)" /> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsAspireHost>true</IsAspireHost> | ||
<UserSecretsId>cb846a57-bdaf-4abd-a7fb-0299aa095f5e</UserSecretsId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Aspire.Hosting" /> | ||
<PackageReference Include="Aspire.Hosting.AppHost" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\src\CommunityToolkit.Aspire.Hosting.LavinMQ\CommunityToolkit.Aspire.Hosting.LavinMQ.csproj" IsAspireProjectResource="false" /> | ||
<ProjectReference Include="..\CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit\CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
13 changes: 13 additions & 0 deletions
13
examples/lavinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.AppHost/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Projects; | ||
|
||
var builder = DistributedApplication.CreateBuilder(args); | ||
|
||
var lavinmq = builder.AddLavinMQ("lavinmq") | ||
.PublishAsConnectionString(); | ||
|
||
builder.AddProject<CommunityToolkit_Aspire_Hosting_LavinMQ_MassTransit>("masstransitExample") | ||
.WithReference(lavinmq) | ||
.WithHttpHealthCheck(path: "/health") | ||
.WaitFor(lavinmq); | ||
|
||
builder.Build().Run(); |
29 changes: 29 additions & 0 deletions
29
...es/lavinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.AppHost/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:17276;http://localhost:15246", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"DOTNET_ENVIRONMENT": "Development", | ||
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21269", | ||
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22000" | ||
} | ||
}, | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "http://localhost:15246", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"DOTNET_ENVIRONMENT": "Development", | ||
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19099", | ||
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20012" | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
examples/lavinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.AppHost/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...re.Hosting.LavinMQ.MassTransit/CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="MassTransit" /> | ||
<PackageReference Include="MassTransit.RabbitMQ" /> | ||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\CommunityToolkit.Aspire.Hosting.LavinMQ.ServiceDefaults\CommunityToolkit.Aspire.Hosting.LavinMQ.ServiceDefaults.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
13 changes: 13 additions & 0 deletions
13
...pire.Hosting.LavinMQ.MassTransit/CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit.http
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit_HostAddress = http://localhost:5004 | ||
|
||
POST http://localhost:5004/send/Hello%20World | ||
Accept: application/json | ||
|
||
### | ||
GET http://localhost:5004/alive | ||
Accept: application/json | ||
|
||
### | ||
GET http://localhost:5004/received | ||
Accept: application/json | ||
|
16 changes: 16 additions & 0 deletions
16
examples/lavinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit/HelloWorldConsumer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using MassTransit; | ||
|
||
namespace CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit; | ||
|
||
public class HelloWorldConsumer(ILogger<HelloWorldConsumer> logger, MessageCounter messageCounter) : IConsumer<Message> | ||
{ | ||
public async Task Consume(ConsumeContext<Message> context) | ||
{ | ||
logger.LogInformation("Received message: {Text}", context.Message.Text); | ||
messageCounter.ReceivedMessages++; | ||
await context.RespondAsync<MessageReply>(new | ||
{ | ||
Reply = "I've received your message: " + context.Message.Text | ||
}); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
examples/lavinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit/Message.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit; | ||
|
||
public record Message | ||
{ | ||
public required string Text { get; set; } | ||
} |
6 changes: 6 additions & 0 deletions
6
examples/lavinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit/MessageCounter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit; | ||
|
||
public class MessageCounter | ||
{ | ||
public int ReceivedMessages { get; set; } | ||
} |
6 changes: 6 additions & 0 deletions
6
examples/lavinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit/MessageReply.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit; | ||
|
||
public record MessageReply | ||
{ | ||
public required string Reply { get; set; } | ||
} |
39 changes: 39 additions & 0 deletions
39
examples/lavinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit; | ||
using MassTransit; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
builder.AddServiceDefaults(); | ||
builder.Services | ||
.AddSingleton(KebabCaseEndpointNameFormatter.Instance) | ||
.AddSingleton<MessageCounter>(); | ||
builder.Services.AddMassTransit(x => | ||
{ | ||
x.UsingRabbitMq((context, cfg) => | ||
{ | ||
string connectionString = builder.Configuration.GetConnectionString("lavinmq")!; | ||
cfg.ConfigureEndpoints(context, new KebabCaseEndpointNameFormatter("aspire", false)); | ||
cfg.Host(new Uri(connectionString), _ => {}); | ||
}); | ||
x.AddConsumers(typeof(HelloWorldConsumer).Assembly); | ||
}); | ||
|
||
WebApplication app = builder.Build(); | ||
|
||
app.MapPost("/send/{text}", async (string text, | ||
[FromServices] IRequestClient<Message> requestClient, | ||
[FromServices] ILogger<Program> logger) => | ||
{ | ||
logger.LogInformation("Send message: {Text}", text); | ||
Response<MessageReply> response = await requestClient.GetResponse<MessageReply>(new { Text = text }); | ||
logger.LogInformation("Sent message: {Text}", text); | ||
return response.Message.Reply; | ||
}) | ||
.WithName("SendMessage"); | ||
|
||
app.MapGet("/received", ([FromServices] MessageCounter messageCounter) => messageCounter) | ||
.WithName("ReceivedMessages"); | ||
|
||
app.MapDefaultEndpoints(); | ||
app.Run(); |
23 changes: 23 additions & 0 deletions
23
...avinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": false, | ||
"applicationUrl": "http://localhost:5004", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": false, | ||
"applicationUrl": "https://localhost:7038;http://localhost:5004", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
examples/lavinmq/CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"ConnectionStrings": { | ||
"lavinmq": "amqp://localhost:5672" | ||
}, | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*" | ||
} |
21 changes: 21 additions & 0 deletions
21
...ng.LavinMQ.ServiceDefaults/CommunityToolkit.Aspire.Hosting.LavinMQ.ServiceDefaults.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsAspireSharedProject>true</IsAspireSharedProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
|
||
<PackageReference Include="Microsoft.Extensions.Http.Resilience" /> | ||
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" /> | ||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" /> | ||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.