Skip to content
Open
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
26 changes: 16 additions & 10 deletions AppyNox.sln
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IntegrationTests", "Integra
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppyNox.Services.Sso.WebAPI.IntegrationTest", "src\Services\SsoService\Tests\IntegrationTests\AppyNox.Services.Sso.WebAPI.IntegrationTest\AppyNox.Services.Sso.WebAPI.IntegrationTest.csproj", "{6D36FEB5-B1D5-4E6D-B3B4-18531447D5F7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmarks", "Benchmarks", "{909B33DD-BC66-411C-9CDD-27FCFB39A11E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppyNox.Services.Coupon.Benchmark", "src\Services\CouponService\Tests\Benchmarks\AppyNox.Services.Coupon.Benchmark\AppyNox.Services.Coupon.Benchmark.csproj", "{BB4BC444-008B-475A-9A8D-6F64FFE6B67F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{5C856BDB-DCFD-4B09-8AAB-24AFA598DB1D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppyNox.Services.Sso.Server.UI", "src\Services\SsoService\Presentation\AppyNox.Services.Sso.Server.UI\AppyNox.Services.Sso.Server.UI.csproj", "{BDF26F8F-070C-47F2-B270-A9D5198ED1DC}"
Expand Down Expand Up @@ -168,6 +164,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\publish-nuget.yml = .github\workflows\publish-nuget.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Aspire", "Aspire", "{B85D7137-4A4F-4ADF-8A96-2C494C059913}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppyNox.ServiceDefaults", "src\Aspire\AppyNox.ServiceDefaults\AppyNox.ServiceDefaults.csproj", "{DD85F606-E42C-49FD-8086-04C9F5CA406F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppyNox.AppHost", "src\Aspire\AppyNox.AppHost\AppyNox.AppHost.csproj", "{94CD6A5F-15ED-4FF3-9C33-F08A5DC92755}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -306,10 +308,6 @@ Global
{6D36FEB5-B1D5-4E6D-B3B4-18531447D5F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D36FEB5-B1D5-4E6D-B3B4-18531447D5F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D36FEB5-B1D5-4E6D-B3B4-18531447D5F7}.Release|Any CPU.Build.0 = Release|Any CPU
{BB4BC444-008B-475A-9A8D-6F64FFE6B67F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BB4BC444-008B-475A-9A8D-6F64FFE6B67F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BB4BC444-008B-475A-9A8D-6F64FFE6B67F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BB4BC444-008B-475A-9A8D-6F64FFE6B67F}.Release|Any CPU.Build.0 = Release|Any CPU
{BDF26F8F-070C-47F2-B270-A9D5198ED1DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BDF26F8F-070C-47F2-B270-A9D5198ED1DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BDF26F8F-070C-47F2-B270-A9D5198ED1DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -330,6 +328,14 @@ Global
{0B11E729-D546-487A-A5C6-9614AC5D6CF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B11E729-D546-487A-A5C6-9614AC5D6CF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B11E729-D546-487A-A5C6-9614AC5D6CF3}.Release|Any CPU.Build.0 = Release|Any CPU
{DD85F606-E42C-49FD-8086-04C9F5CA406F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD85F606-E42C-49FD-8086-04C9F5CA406F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD85F606-E42C-49FD-8086-04C9F5CA406F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD85F606-E42C-49FD-8086-04C9F5CA406F}.Release|Any CPU.Build.0 = Release|Any CPU
{94CD6A5F-15ED-4FF3-9C33-F08A5DC92755}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94CD6A5F-15ED-4FF3-9C33-F08A5DC92755}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94CD6A5F-15ED-4FF3-9C33-F08A5DC92755}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94CD6A5F-15ED-4FF3-9C33-F08A5DC92755}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -383,8 +389,6 @@ Global
{E6F09B37-DBB4-45BD-B81A-72A610BBE021} = {14E3528C-2F6B-4296-BAD1-E91F32F679EC}
{5D153F77-0942-4DA5-8655-AEDB92339738} = {C17866BD-9B28-4516-B3D7-FCBEFE171801}
{6D36FEB5-B1D5-4E6D-B3B4-18531447D5F7} = {5D153F77-0942-4DA5-8655-AEDB92339738}
{909B33DD-BC66-411C-9CDD-27FCFB39A11E} = {5BAC57A7-56E7-4E7C-9118-24F61870BA91}
{BB4BC444-008B-475A-9A8D-6F64FFE6B67F} = {909B33DD-BC66-411C-9CDD-27FCFB39A11E}
{5C856BDB-DCFD-4B09-8AAB-24AFA598DB1D} = {AD2F15A2-813D-422E-A37D-BED8810752C6}
{BDF26F8F-070C-47F2-B270-A9D5198ED1DC} = {5C856BDB-DCFD-4B09-8AAB-24AFA598DB1D}
{8EA810B2-F47D-4E10-9E8A-DC9EA663DB69} = {AD2F15A2-813D-422E-A37D-BED8810752C6}
Expand All @@ -395,6 +399,8 @@ Global
{FC84AF5D-DCC5-46C4-A93C-6047FDDACF26} = {EE924FAE-1536-4E54-A2E0-6698107A548C}
{A649C5A6-11AB-4716-A7A4-54FFD327179D} = {FC84AF5D-DCC5-46C4-A93C-6047FDDACF26}
{B54046FA-AC1E-4644-9985-4C233E986F33} = {FC84AF5D-DCC5-46C4-A93C-6047FDDACF26}
{DD85F606-E42C-49FD-8086-04C9F5CA406F} = {B85D7137-4A4F-4ADF-8A96-2C494C059913}
{94CD6A5F-15ED-4FF3-9C33-F08A5DC92755} = {B85D7137-4A4F-4ADF-8A96-2C494C059913}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EA4F2302-DC43-4149-814A-609940BEC847}
Expand Down
31 changes: 31 additions & 0 deletions src/Aspire/AppyNox.AppHost/AppyNox.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>df1762e9-7e42-475a-a8af-7e1dc8bbc26d</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting" Version="9.0.0" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.0.0" />
<PackageReference Include="Aspire.Hosting.PostgreSQL" 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.Seq" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Gateways\AppyNox.Gateway.OcelotGateway\AppyNox.Gateway.OcelotGateway.csproj" />
<ProjectReference Include="..\..\Services\CouponService\AppyNox.Services.Coupon.WebAPI\AppyNox.Services.Coupon.WebAPI.csproj" />
<ProjectReference Include="..\..\Services\LicenseService\AppyNox.Services.License.WebAPI\AppyNox.Services.License.WebAPI.csproj" />
<ProjectReference Include="..\..\Services\SsoService\AppyNox.Services.Sso.WebAPI\AppyNox.Services.Sso.WebAPI.csproj" />
</ItemGroup>

</Project>
74 changes: 74 additions & 0 deletions src/Aspire/AppyNox.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using Projects;

var builder = DistributedApplication.CreateBuilder(args);
var configuration = builder.Configuration;

var db = builder.AddPostgres("appynox-db")
.WithDataVolume("appynox-db-volume")
.WithPgAdmin();

var ssoDb = db.AddDatabase("appynox-sso-db", "AppyNox_Sso");
var ssoSagaDb = db.AddDatabase("appynox-sso-saga-db", "AppyNox_Sso_Saga");
var licenseDb = db.AddDatabase("appynox-license-db", "AppyNox_License");
var couponDb = db.AddDatabase("appynox-coupon-db", "AppyNox_Coupon");

var redis = builder.AddRedis("appynox-cache")
.WithRedisInsight();

var consul = builder.AddContainer("appynox-consul", "")
.WithImageRegistry("hashicorp")
.WithImage("consul")
.WithHttpEndpoint(8500, 8500);

var seq = builder.AddSeq("seq")
.ExcludeFromManifest();

// For NoxLogger
var appynoxSeq = builder.AddSeq("appynox-seq")
.ExcludeFromManifest();

var internalRabbitmqUsername = builder.AddParameter(configuration["MessageBroker:Internal:Username"] ?? "quest");
var internalRabbitmqPassword = builder.AddParameter(configuration["MessageBroker:Internal:Password"] ?? "quest");
var externalRabbitmqUsername = builder.AddParameter(configuration["MessageBroker:External:Username"] ?? "quest");
var externalRabbitmqPassword = builder.AddParameter(configuration["MessageBroker:External:Password"] ?? "quest");

var internalRabbitmq = builder.AddRabbitMQ("appynox-rabbitmq", internalRabbitmqUsername, internalRabbitmqPassword, 5672)
.WithManagementPlugin();

var externalRabbitmq = builder.AddRabbitMQ("external-rabbitmq", externalRabbitmqUsername, externalRabbitmqPassword, port: 5673)
.WithManagementPlugin();

var ssoApi = builder.AddProject<AppyNox_Services_Sso_WebAPI>("appynox-sso-api")
.WithReference(redis)
.WithReference(internalRabbitmq)
.WithReference(externalRabbitmq)
.WithReference(ssoDb)
.WithReference(ssoSagaDb)
.WithReference(seq)
.WithReference(appynoxSeq)
.WaitFor(consul)
.WaitFor(internalRabbitmq)
.WaitFor(externalRabbitmq);

var couponApi = builder.AddProject<AppyNox_Services_Coupon_WebAPI>("appynox-coupon-api")
.WithReference(redis)
.WithReference(internalRabbitmq)
.WithReference(couponDb)
.WithReference(seq)
.WithReference(appynoxSeq)
.WaitFor(consul)
.WaitFor(internalRabbitmq);

var licenseApi = builder.AddProject<AppyNox_Services_License_WebAPI>("appynox-license-api")
.WithReference(redis)
.WithReference(internalRabbitmq)
.WithReference(licenseDb)
.WithReference(seq)
.WithReference(appynoxSeq)
.WaitFor(consul)
.WaitFor(internalRabbitmq);

var gateway = builder.AddProject<AppyNox_Gateway_OcelotGateway>("appynox-gateway")
.WaitFor(consul);

builder.Build().Run();
29 changes: 29 additions & 0 deletions src/Aspire/AppyNox.AppHost/Properties/launchSettings.json
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:17129;http://localhost:15159",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21103",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22077"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15159",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19083",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20162"
}
}
}
}
24 changes: 24 additions & 0 deletions src/Aspire/AppyNox.AppHost/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"MessageBroker": {
"Internal": {
"Username": "HappiInternalUsername",
"Password": "HappiInternalPassword"
},
"External": {
"Username": "HappiExternalUsername",
"Password": "HappiExternalPassword"
}
},
"Parameters": {
"HappiInternalUsername": "Happi",
"HappiInternalPassword": "Happi",
"HappiExternalUsername": "Happi",
"HappiExternalPassword": "Happi"
}
}
9 changes: 9 additions & 0 deletions src/Aspire/AppyNox.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"
}
}
}
22 changes: 22 additions & 0 deletions src/Aspire/AppyNox.ServiceDefaults/AppyNox.ServiceDefaults.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireSharedProject>true</IsAspireSharedProject>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.0.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0" />
</ItemGroup>

</Project>
120 changes: 120 additions & 0 deletions src/Aspire/AppyNox.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.ServiceDiscovery;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;

namespace Microsoft.Extensions.Hosting
{
// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
// This project should be referenced by each service project in your solution.
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
public static class Extensions
{
public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.ConfigureOpenTelemetry();

builder.AddDefaultHealthChecks();

builder.Services.AddServiceDiscovery();

builder.Services.ConfigureHttpClientDefaults(http =>
{
// Turn on resilience by default
http.AddStandardResilienceHandler();

// Turn on service discovery by default
http.AddServiceDiscovery();
});

// Uncomment the following to restrict the allowed schemes for service discovery.
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
// {
// options.AllowedSchemes = ["https"];
// });

return builder;
}

public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.Logging.AddOpenTelemetry(logging =>
{
logging.IncludeFormattedMessage = true;
logging.IncludeScopes = true;
});

builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation();
})
.WithTracing(tracing =>
{
tracing.AddSource(builder.Environment.ApplicationName)
.AddAspNetCoreInstrumentation()
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
//.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation();
});

builder.AddOpenTelemetryExporters();

return builder;
}

private static TBuilder AddOpenTelemetryExporters<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);

if (useOtlpExporter)
{
builder.Services.AddOpenTelemetry().UseOtlpExporter();
}

// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
//{
// builder.Services.AddOpenTelemetry()
// .UseAzureMonitor();
//}

return builder;
}

public static TBuilder AddDefaultHealthChecks<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.Services.AddHealthChecks()
// Add a default liveness check to ensure app is responsive
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);

return builder;
}

public static WebApplication MapDefaultEndpoints(this WebApplication app)
{
// Adding health checks endpoints to applications in non-development environments has security implications.
// See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
if (app.Environment.IsDevelopment())
{
// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks("/health");

// Only health checks tagged with the "live" tag must pass for app to be considered alive
app.MapHealthChecks("/alive", new HealthCheckOptions
{
Predicate = r => r.Tags.Contains("live")
});
}

return app;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public static void ConfigureNoxApi(this WebApplication app, Action<ApiOptions> c
{
PerformAutoMapperChecks(app);
}

app.MapDefaultEndpoints();
}

private static void ConfigureLocalization(this WebApplication app, ApiOptions options)
Expand Down
Loading