Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Alirexaa committed Dec 13, 2024
1 parent dda11db commit 133fd97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/HealthChecks.Nats/NatsHealthCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public sealed class NatsHealthCheck(INatsConnection connection) : IHealthCheck
{
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
await TryConnectAsync(connection).ConfigureAwait(false);

var result = connection.ConnectionState switch
{
NatsConnectionState.Open => HealthCheckResult.Healthy(),
Expand Down
16 changes: 8 additions & 8 deletions test/HealthChecks.Nats.Tests/Functional/NatsHealthCheckTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Net;
using NATS.Client.Core;
using NATS.Client.Hosting;
using static HealthChecks.Nats.Tests.Defines;

namespace HealthChecks.Nats.Tests.Functional;
Expand All @@ -12,17 +13,16 @@ public async Task be_healthy_when_nats_is_available_using_client_factory()
var webHostBuilder = new WebHostBuilder()
.ConfigureServices(services =>
{
var options = NatsOpts.Default with
{
Url = DefaultLocalConnectionString,
};
var natsConnection = new NatsConnection(options);

services
.AddHealthChecks()
.AddNats(
clientFactory: sp =>
{
var options = NatsOpts.Default with
{
Url = DefaultLocalConnectionString,
};
return new NatsConnection(options);
}, tags: new string[] { "nats" });
clientFactory: sp => natsConnection, tags: new string[] { "nats" });
})
.Configure(app =>
{
Expand Down

0 comments on commit 133fd97

Please sign in to comment.