-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
401 additions
and
59 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
41 changes: 41 additions & 0 deletions
41
CleanArchitecture.Api/Extensions/ConfigurationExtensions.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,41 @@ | ||
using System; | ||
using CleanArchitecture.Domain.Rabbitmq; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace CleanArchitecture.Api.Extensions; | ||
|
||
public static class ConfigurationExtensions | ||
{ | ||
public static RabbitMqConfiguration GetRabbitMqConfiguration( | ||
this IConfiguration configuration) | ||
{ | ||
var isAspire = configuration["ASPIRE_ENABLED"] == "true"; | ||
|
||
var rabbitEnabled = configuration["RabbitMQ:Enabled"]; | ||
var rabbitHost = configuration["RabbitMQ:Host"]; | ||
var rabbitPort = configuration["RabbitMQ:Port"]; | ||
var rabbitUser = configuration["RabbitMQ:Username"]; | ||
var rabbitPass = configuration["RabbitMQ:Password"]; | ||
|
||
if (isAspire) | ||
{ | ||
rabbitEnabled = "true"; | ||
var connectionString = configuration["ConnectionStrings:RabbitMq"]; | ||
|
||
var rabbitUri = new Uri(connectionString!); | ||
rabbitHost = rabbitUri.Host; | ||
rabbitPort = rabbitUri.Port.ToString(); | ||
rabbitUser = rabbitUri.UserInfo.Split(':')[0]; | ||
rabbitPass = rabbitUri.UserInfo.Split(':')[1]; | ||
} | ||
|
||
return new RabbitMqConfiguration() | ||
{ | ||
Host = rabbitHost ?? "", | ||
Port = int.Parse(rabbitPort ?? "0"), | ||
Enabled = bool.Parse(rabbitEnabled ?? "false"), | ||
Username = rabbitUser ?? "", | ||
Password = rabbitPass ?? "" | ||
}; | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
CleanArchitecture.AppHost/CleanArchitecture.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,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" /> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsAspireHost>true</IsAspireHost> | ||
<UserSecretsId>e7ec3788-69e9-4631-b350-d59657ddd747</UserSecretsId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.0.0" /> | ||
<PackageReference Include="Aspire.Hosting.RabbitMQ" Version="9.0.0" /> | ||
<PackageReference Include="Aspire.Hosting.Redis" Version="9.0.0" /> | ||
<PackageReference Include="Aspire.Hosting.SqlServer" Version="9.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\CleanArchitecture.Api\CleanArchitecture.Api.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,26 @@ | ||
var builder = DistributedApplication.CreateBuilder(args); | ||
|
||
var redis = builder.AddRedis("Redis").WithRedisInsight(); | ||
|
||
var rabbitPasswordRessource = new ParameterResource("password", _ => "guest"); | ||
var rabbitPasswordParameter = | ||
builder.AddParameter("username", rabbitPasswordRessource.Value); | ||
|
||
var rabbitMq = builder | ||
.AddRabbitMQ("RabbitMq", null, rabbitPasswordParameter, 5672) | ||
.WithManagementPlugin(); | ||
|
||
var sqlServer = builder.AddSqlServer("SqlServer"); | ||
var db = sqlServer.AddDatabase("Database", "clean-architecture"); | ||
|
||
builder.AddProject<Projects.CleanArchitecture_Api>("CleanArchitecture-Api") | ||
.WithOtlpExporter() | ||
.WithHttpHealthCheck("/health") | ||
.WithReference(redis) | ||
.WaitFor(redis) | ||
.WithReference(rabbitMq) | ||
.WaitFor(rabbitMq) | ||
.WithReference(db) | ||
.WaitFor(sqlServer); | ||
|
||
builder.Build().Run(); |
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 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"Aspire": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:17270;http://localhost:15188", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"DOTNET_ENVIRONMENT": "Development", | ||
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21200", | ||
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22111", | ||
"ASPIRE_ENABLED": "true" | ||
} | ||
} | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning" | ||
} | ||
} | ||
} |
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" | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.