Skip to content
Merged
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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v7.1.0](https://github.com/Genocs/genocs-library/compare/v7.0.0...v7.1.0)

> 29 November 2024

- Update packages and refactor MongoDB repository methods [`#126`](https://github.com/Genocs/genocs-library/pull/126)
- Ver 700 [`#125`](https://github.com/Genocs/genocs-library/pull/125)
- Update CHANGELOG for v7.0.0 release with recent changes and improvements [`#121`](https://github.com/Genocs/genocs-library/pull/121)
- Refactor RabbitMQ client to use async methods [`d5cf8ab`](https://github.com/Genocs/genocs-library/commit/d5cf8abe6b4a4a21712579373858431ea3f5589c)
- Update appsettings and refactor code for services [`b9e6e8c`](https://github.com/Genocs/genocs-library/commit/b9e6e8c43a700c1865f1ed23c561b0c69a4ce417)
- Update Docker, health checks, and service configurations [`828c7a7`](https://github.com/Genocs/genocs-library/commit/828c7a775b3eb095204e5df0e62614bfbebe6705)
- Add .env template, update appsettings for Docker compatibility, and modify service configurations [`c3c6488`](https://github.com/Genocs/genocs-library/commit/c3c64884098deafec6053bd3838eaefbb67bc4ea)
- Update package references to Genocs.Core and related packages to version 7.1.0 [`a8b8c4a`](https://github.com/Genocs/genocs-library/commit/a8b8c4a9baff9e54c9e38a0cd20bad4bbea5a0dd)
- Refactor and update nullability and configurations [`992c33d`](https://github.com/Genocs/genocs-library/commit/992c33d33e686d5f573d899c911cd297ad086637)
- Refactor constructors and update Program.cs endpoints [`4f14136`](https://github.com/Genocs/genocs-library/commit/4f14136419cb43d8619721f02ce4082c92d880fb)
- Refactor service registration and update dependencies [`78a7892`](https://github.com/Genocs/genocs-library/commit/78a789238db6c2e6def7b1d8103facf1092191e5)
- Upgrade packages and modify NotificationId property [`77bbd75`](https://github.com/Genocs/genocs-library/commit/77bbd75766d14dcde87d386e84e3ccfb248a5062)
- Disable Azure logging and clear connection strings [`3a44081`](https://github.com/Genocs/genocs-library/commit/3a440812ef71aa64ecf0a1a829943d8c2723edd6)

### [v7.0.0](https://github.com/Genocs/genocs-library/compare/v6.4.0...v7.0.0)

> 24 November 2024
Expand Down
42 changes: 26 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ You can use **Docker compose** to setup the infrastructure components just by ru

``` bash
cd ./containers
# Setup the infrastructure
# Setup the infrastructure. Use this file to setup the basic infrastructure components (RabbitMQ, MongoDB)
docker compose -f ./infrastructure.yml --env-file ./.env --project-name genocs up -d

# Use this file only in case you want to setup Redis and Postgres db (no need if you use mongo)
# Use this file only in case you want to setup Redis and PostgreSQL (no need if you use MongoDB)
docker compose -f ./infrastructure-db.yml --env-file ./.env --project-name genocs up -d

# Use this file only in case you want to setup monitoring infrastructure components (Prometheus, Grafana, InfluxDB, Jaeger, Seq)
Expand All @@ -88,13 +88,13 @@ docker compose -f ./infrastructure-scaling.yml --env-file ./.env --project-name
# Use this file only in case you want to setup security infrastructure components (Vault)
docker compose -f ./infrastructure-security.yml --env-file ./.env --project-name genocs up -d

# Use this file only in case you want to setup sqlserver database (no need if you use postgres)
# Use this file only in case you want to setup sqlserver database (no need if you use PostgreSQL)
docker compose -f ./infrastructure-sqlserver.yml --env-file ./.env --project-name genocs up -d

# Use this file only in case you want to setup mySql database (no need if you use postgres)
# Use this file only in case you want to setup mySql database (no need if you use PostgreSQL)
docker compose -f ./infrastructure-mysql.yml --env-file ./.env --project-name genocs up -d

# Use this file only in case you want to setup oracle database (no need if you use postgres)
# Use this file only in case you want to setup oracle database (no need if you use PostgreSQL)
docker compose -f ./infrastructure-oracle.yml --env-file ./.env --project-name genocs up -d

# Use this file only in case you want to setup elk stack
Expand All @@ -104,18 +104,24 @@ docker compose -f ./infrastructure-elk.yml --env-file ./.env --project-name geno
docker compose -f ./infrastructure-ml.yml --env-file ./.env --project-name genocs up -d
```

`infrastructure-bare.yml` allows to install the basic infrastructure components. They are:
`infrastructure.yml` allows to install the basic infrastructure components. They are:
- [RabbitMQ](https://rabbitmq.com)
- [Redis](https://redis.io)
- [MongoDB](https://mongodb.com)
- [Postgres](https://www.postgresql.org/).
- [Postgres](https://www.postgresql.org/)

You can run them locally:

`infrastructure-db.yml` allows to install Redis and PostgreSQL
- [Redis](https://redis.io)
- [Postgres](https://www.postgresql.org/)


You can check them locally:

- [RabbitMQ](http://localhost:15672): `localhost:15672`
- Redis: `localhost:6379`
- MongoDB: `localhost:27017`
- Postgres: `localhost:5432`
- Redis: `TCP:localhost:6379`
- MongoDB: `TCP:localhost:27017`
- Postgres: `TCP:localhost:5432`


`infrastructure-monitoring.yml` allows to install the monitoring infrastructure components. They are:
Expand All @@ -126,7 +132,7 @@ You can run them locally:
- [Seq](https://datalust.co/seq)


You can run them locally:
You can find the console locally at:

- [Prometheus](localhost:9090): `localhost:9090`
- [Grafana](localhost:3000): `localhost:3000`
Expand All @@ -135,9 +141,13 @@ You can run them locally:
- [Seq](localhost:5341): `localhost:5341`


`infrastructure-scaling.yml` allows to install the scaling infrastructure components. They are:
- Fabio
- Consul
`infrastructure-scaling.yml` allows to install the scaling infrastructure components composed by Fabio and Consul.

- [Fabio](https://fabiolb.net/)
- [Consul](https://www.consul.io/)




`infrastructure-security.yml` allows to install the security infrastructure components.

Expand Down Expand Up @@ -185,7 +195,7 @@ Use [**api-workbench**](./api-workbench.rest) inside Visual Studio code with [RE
"enabled": false,
"url": "http://localhost:8500",
"service": "demo-service",
"address": "docker.for.win.localhost",
"address": "docker.for.mac.localhost",
"port": "5070",
"pingEnabled": true,
"pingEndpoint": "health",
Expand Down
2 changes: 2 additions & 0 deletions containers/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file is a template for the .env file that is used by the docker-compose.yml file.
POSTGRES_PASSWORD=mySecretPassword1234!
4 changes: 3 additions & 1 deletion genocs.sln
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{B184733D-2415-4517-BC65-26ED22EEB2C2}"
ProjectSection(SolutionItems) = preProject
src\apps\apigateway.dockerfile = src\apps\apigateway.dockerfile
src\apps\application-docker-compose.yml = src\apps\application-docker-compose.yml
src\apps\docker-compose.override.yml = src\apps\docker-compose.override.yml
src\apps\docker-compose.yml = src\apps\docker-compose.yml
src\apps\identity-webapi.dockerfile = src\apps\identity-webapi.dockerfile
src\apps\order-webapi.dockerfile = src\apps\order-webapi.dockerfile
src\apps\local.env = src\apps\local.env
src\apps\product-webapi.dockerfile = src\apps\product-webapi.dockerfile
src\apps\signalr-webapi.dockerfile = src\apps\signalr-webapi.dockerfile
EndProjectSection
Expand Down
4 changes: 2 additions & 2 deletions src/Genocs.Auth/Genocs.Auth.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.Core" Version="7.0.0" />
<PackageReference Include="Genocs.Security" Version="7.0.0" />
<PackageReference Include="Genocs.Core" Version="7.1.0" />
<PackageReference Include="Genocs.Security" Version="7.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.Core" Version="7.0.0" />
<PackageReference Include="Genocs.Core" Version="7.1.0" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/Genocs.Core.Demo.Domain/Genocs.Core.Demo.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.Persistence.MongoDb" Version="7.0.0" />
<PackageReference Include="Genocs.Core" Version="7.0.0" />
<PackageReference Include="Genocs.Persistence.MongoDb" Version="7.1.0" />
<PackageReference Include="Genocs.Core" Version="7.1.0" />
</ItemGroup>

</Project>
20 changes: 10 additions & 10 deletions src/Genocs.Core.Demo.WebApi/Genocs.Core.Demo.WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.ServiceBusAzure" Version="7.0.0" />
<PackageReference Include="Genocs.Auth" Version="7.0.0" />
<PackageReference Include="Genocs.Logging" Version="7.0.0" />
<PackageReference Include="Genocs.Tracing" Version="7.0.0" />
<PackageReference Include="Genocs.HTTP" Version="7.0.0" />
<PackageReference Include="Genocs.Security" Version="7.0.0" />
<PackageReference Include="Genocs.WebApi" Version="7.0.0" />
<PackageReference Include="Genocs.WebApi.Security" Version="7.0.0" />
<PackageReference Include="Genocs.Secrets.AzureKeyVault" Version="7.0.0" />
<PackageReference Include="Genocs.ServiceBusAzure" Version="7.1.0" />
<PackageReference Include="Genocs.Auth" Version="7.1.0" />
<PackageReference Include="Genocs.Logging" Version="7.1.0" />
<PackageReference Include="Genocs.Tracing" Version="7.1.0" />
<PackageReference Include="Genocs.HTTP" Version="7.1.0" />
<PackageReference Include="Genocs.Security" Version="7.1.0" />
<PackageReference Include="Genocs.WebApi" Version="7.1.0" />
<PackageReference Include="Genocs.WebApi.Security" Version="7.1.0" />
<PackageReference Include="Genocs.Secrets.AzureKeyVault" Version="7.1.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Certificate" Version="9.0.0" />
<PackageReference Include="Polly" Version="8.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 3 additions & 4 deletions src/Genocs.Core.Demo.WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
.UseAzureKeyVault()
.UseLogging();

var services = builder.Services;

services
.AddGenocs(builder.Configuration)
builder.AddGenocs()
.AddJwt()
// .AddOpenIdJwt()
.AddOpenTelemetry()
Expand All @@ -32,6 +29,8 @@
.AddApplicationServices()
.Build();

var services = builder.Services;

services.AddCors();
services.AddControllers().AddJsonOptions(x =>
{
Expand Down
6 changes: 3 additions & 3 deletions src/Genocs.Core.Demo.Worker/Genocs.Core.Demo.Worker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.ServiceBusAzure" Version="7.0.0" />
<PackageReference Include="Genocs.Logging" Version="7.0.0" />
<PackageReference Include="Genocs.Tracing" Version="7.0.0" />
<PackageReference Include="Genocs.ServiceBusAzure" Version="7.1.0" />
<PackageReference Include="Genocs.Logging" Version="7.1.0" />
<PackageReference Include="Genocs.Tracing" Version="7.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/Genocs.Core.Demo.Worker/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
"enabled": false,
"url": "http://localhost:8500",
"service": "users-service",
"address": "docker.for.win.localhost",
"address": "docker.for.mac.localhost",
"port": "5070",
"pingEnabled": true,
"pingEndpoint": "ping",
"pingEndpoint": "healthz",
"pingInterval": 3,
"removeAfterInterval": 3
},
Expand Down Expand Up @@ -99,7 +99,7 @@
"interval": "day"
},
"seq": {
"enabled": false,
"enabled": true,
"url": "http://localhost:5341",
"apiKey": "secret"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Genocs.Core.UnitTests/Genocs.Core.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
70 changes: 37 additions & 33 deletions src/Genocs.Core/Builders/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static IGenocsBuilder AddGenocs(this WebApplicationBuilder builder)
{
// Create the builder
IGenocsBuilder gnxBuilder = GenocsBuilder.Create(builder);
Setup(gnxBuilder);
return gnxBuilder;
}

Expand All @@ -33,32 +34,7 @@ public static IGenocsBuilder AddGenocs(this IServiceCollection services, IConfig
{
// Create the builder
IGenocsBuilder builder = GenocsBuilder.Create(services, configuration);

// Get the application options
AppOptions settings = builder.GetOptions<AppOptions>(AppOptions.Position);
builder.Services.AddSingleton(settings);

// Add the health checks
builder.Services
.AddHealthChecks()
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]); // Add a default liveness check to ensure app is responsive

builder.Services.AddMemoryCache();

builder.Services.AddSingleton<IServiceId, ServiceId>();

if (!settings.DisplayBanner || string.IsNullOrWhiteSpace(settings.Name))
{
return builder;
}

string version = settings.DisplayVersion ? $" {settings.Version}" : string.Empty;
Console.WriteLine(Figgle.FiggleFonts.Doom.Render(settings.Name + version));
ConsoleColor current = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Runtime Version: {0}", Environment.Version.ToString());
Console.ForegroundColor = current;

Setup(builder);
return builder;
}

Expand Down Expand Up @@ -160,6 +136,15 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
return app;
}

// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks("/healthz");

// 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")
});

app.MapGet("/", async context =>
{
// Get the Entry Assembly Name and Version
Expand All @@ -170,16 +155,35 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)

await context.Response.WriteAsync(context.RequestServices.GetService<AppOptions>()?.Name ?? message);
});
return app;
}

// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks("/health");
private static void Setup(IGenocsBuilder builder)
{
// Get the application options
AppOptions settings = builder.GetOptions<AppOptions>(AppOptions.Position);
builder.Services.AddSingleton(settings);

// Only health checks tagged with the "live" tag must pass for app to be considered alive
app.MapHealthChecks("/alive", new HealthCheckOptions
if (!settings.DisplayBanner || string.IsNullOrWhiteSpace(settings.Name))
{
Predicate = r => r.Tags.Contains("live")
});
return;
}

return app;
string version = settings.DisplayVersion ? $" {settings.Version}" : string.Empty;
Console.WriteLine(Figgle.FiggleFonts.Doom.Render(settings.Name + version));
ConsoleColor current = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Runtime Version: {0}", Environment.Version.ToString());
Console.ForegroundColor = current;

// Add the health checks
builder.Services
.AddHealthChecks();

// .AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]); // Add a default liveness check to ensure app is responsive

builder.Services.AddMemoryCache();

builder.Services.AddSingleton<IServiceId, ServiceId>();
}
}
2 changes: 1 addition & 1 deletion src/Genocs.Core/Genocs.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.Common" Version="7.0.0" />
<PackageReference Include="Genocs.Common" Version="7.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Genocs.Discovery.Consul/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static void AddConsulHttpClient(this IGenocsBuilder builder, string clien
c.GetRequiredService<IConsulServicesRegistry>(),
c.GetRequiredService<ConsulOptions>(), serviceName, true));

private static ServiceRegistration CreateConsulAgentRegistration(this IGenocsBuilder builder, ConsulOptions options)
private static ServiceRegistration? CreateConsulAgentRegistration(this IGenocsBuilder builder, ConsulOptions options)
{
bool enabled = options.Enabled;
string? consulEnabled = Environment.GetEnvironmentVariable("CONSUL_ENABLED")?.ToLowerInvariant();
Expand Down
Loading