Skip to content

Commit 195aa5a

Browse files
committed
upgraded
1 parent e62ea1d commit 195aa5a

File tree

8 files changed

+61
-18
lines changed

8 files changed

+61
-18
lines changed

src/Pandatech.ModularMonolith.ApiGateway/Program.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using DistributedCache.Extensions;
12
using DistributedCache.Options;
23
using FluentMinimalApiMapper;
34
using Pandatech.Crypto.Extensions;
@@ -17,6 +18,8 @@
1718
builder.LogStartAttempt();
1819
AssemblyRegistry.Add(typeof(Program).Assembly);
1920

21+
var repoName = builder.Environment.GetShortEnvironmentName() + ":" + builder.Configuration.GetRepositoryName();
22+
2023
builder
2124
.ConfigureWithPandaVault()
2225
.AddOutboundLoggingHandler()
@@ -30,8 +33,12 @@
3033
.AddMediatrWithBehaviors(AssemblyRegistry.ToArray())
3134
.AddMassTransit(AssemblyRegistry.ToArray())
3235
.AddResilienceDefaultPipeline()
33-
.AddRedis(KeyPrefix.AssemblyNamePrefix)
34-
.AddDistributedSignalR("DistributedSignalR")
36+
.AddDistributedCache(o =>
37+
{
38+
o.RedisConnectionString = builder.Configuration.GetRedisUrl();
39+
o.ChannelPrefix = repoName;
40+
})
41+
.AddDistributedSignalR(builder.Configuration.GetRedisUrl(), repoName + ":SignalR")
3542
.MapDefaultTimeZone()
3643
.AddCors()
3744
.AddAes256Key(builder.Configuration.GetAesKey())

src/Pandatech.ModularMonolith.ApiGateway/appsettings.Production.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"MinimumLevel": {
44
"Default": "Information",
55
"Override": {
6-
"Microsoft": "Information",
7-
"System": "Information"
6+
"Microsoft": "Warning",
7+
"System": "Warning"
88
}
99
}
1010
},

src/Pandatech.ModularMonolith.Mock1/Pandatech.ModularMonolith.Mock1.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</ItemGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.1">
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.2">
1111
<PrivateAssets>all</PrivateAssets>
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
</PackageReference>

src/Pandatech.ModularMonolith.Mock2/Pandatech.ModularMonolith.Mock2.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</ItemGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.1">
9+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.2">
1010
<PrivateAssets>all</PrivateAssets>
1111
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1212
</PackageReference>

src/Pandatech.ModularMonolith.Scheduler/Pandatech.ModularMonolith.Scheduler.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<ItemGroup>
4-
<PackageReference Include="Hangfire" Version="1.8.17" />
4+
<PackageReference Include="Hangfire" Version="1.8.18" />
55
<PackageReference Include="Hangfire.Dashboard.Basic.Authentication" Version="7.0.1"/>
6-
<PackageReference Include="Hangfire.EntityFrameworkCore" Version="0.6.0"/>
6+
<PackageReference Include="Hangfire.EntityFrameworkCore" Version="0.7.0" />
77
<PackageReference Include="Hangfire.PostgreSql" Version="1.20.10"/>
88
</ItemGroup>
99

src/Pandatech.ModularMonolith.SharedKernel/Extensions/MassTransitExtension.cs

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
using MassTransit;
33
using Microsoft.AspNetCore.Builder;
44
using Microsoft.Extensions.Configuration;
5+
using Microsoft.Extensions.DependencyInjection;
6+
using Microsoft.Extensions.Diagnostics.HealthChecks;
7+
using RabbitMQ.Client;
58

69
namespace Pandatech.ModularMonolith.SharedKernel.Extensions;
710

@@ -13,18 +16,51 @@ public static WebApplicationBuilder AddMassTransit(this WebApplicationBuilder bu
1316
{
1417
x.AddConsumers(assemblies);
1518
x.SetKebabCaseEndpointNameFormatter();
16-
17-
1819
x.UsingRabbitMq((context, cfg) =>
1920
{
20-
cfg.Host(builder.Configuration.GetConnectionString(builder.Configuration.GetRabbitMqUrl()));
21+
cfg.Host(builder.Configuration.GetRabbitMqUrl());
2122
cfg.ConfigureEndpoints(context);
2223
cfg.UseMessageRetry(r =>
23-
r.Exponential(10, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(100), TimeSpan.FromSeconds(2)));
24+
r.Exponential(5, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(2)));
2425
});
2526
});
2627

28+
builder
29+
.Services
30+
.AddHealthChecks()
31+
.AddCheck<RabbitMqHealthCheck>("rabbit_mq", timeout: TimeSpan.FromSeconds(3));
2732

2833
return builder;
2934
}
35+
}
36+
37+
public class RabbitMqHealthCheck(IConfiguration configuration) : IHealthCheck
38+
{
39+
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context,
40+
CancellationToken cancellationToken = new())
41+
{
42+
var rmqConnectionString = configuration.GetRabbitMqUrl();
43+
var factory = new ConnectionFactory
44+
{
45+
Uri = new Uri(rmqConnectionString),
46+
AutomaticRecoveryEnabled = true
47+
};
48+
var connection = default(IConnection);
49+
try
50+
{
51+
connection = await factory.CreateConnectionAsync(cancellationToken);
52+
return HealthCheckResult.Healthy("RabbitMQ is healthy.");
53+
}
54+
catch (Exception e)
55+
{
56+
return HealthCheckResult.Unhealthy("RabbitMQ is unhealthy.", e);
57+
}
58+
finally
59+
{
60+
if (connection is not null)
61+
{
62+
await connection.CloseAsync(cancellationToken);
63+
}
64+
}
65+
}
3066
}

src/Pandatech.ModularMonolith.SharedKernel/Pandatech.ModularMonolith.SharedKernel.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33

44
<ItemGroup>
5-
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.4" />
6-
<PackageReference Include="Pandatech.MassTransit.PostgresOutbox" Version="2.0.2"/>
7-
<PackageReference Include="Pandatech.SharedKernel" Version="1.1.1" />
8-
<PackageReference Include="Pandatech.SharedKernel.Postgres" Version="1.0.15" />
5+
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.6" />
6+
<PackageReference Include="Pandatech.MassTransit.PostgresOutbox" Version="2.0.3" />
7+
<PackageReference Include="Pandatech.SharedKernel" Version="1.2.10" />
8+
<PackageReference Include="Pandatech.SharedKernel.Postgres" Version="1.0.18" />
99
</ItemGroup>
1010

1111

test/Pandatech.ModularMonolith.E2ETests/Pandatech.ModularMonolith.E2ETests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
77
</PackageReference>
88
<PackageReference Include="FluentAssertions" Version="[7.1.0]" />
9-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0"/>
9+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
1010
<PackageReference Include="NetArchTest.Rules" Version="1.3.2"/>
1111
<PackageReference Include="xunit" Version="2.9.3" />
12-
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
12+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
1313
<PrivateAssets>all</PrivateAssets>
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
</PackageReference>

0 commit comments

Comments
 (0)