From c5b72385342b19593ab682af9115d8686ddcb018 Mon Sep 17 00:00:00 2001 From: Alireza Baloochi Date: Fri, 13 Dec 2024 21:57:52 +0330 Subject: [PATCH] Addresss PR feedback --- src/HealthChecks.Nats/NatsHealthCheck.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/HealthChecks.Nats/NatsHealthCheck.cs b/src/HealthChecks.Nats/NatsHealthCheck.cs index b10a12b647..9e444c2cb8 100644 --- a/src/HealthChecks.Nats/NatsHealthCheck.cs +++ b/src/HealthChecks.Nats/NatsHealthCheck.cs @@ -8,21 +8,9 @@ namespace HealthChecks.Nats; /// public sealed class NatsHealthCheck(INatsConnection connection) : IHealthCheck { - public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) - { + public async Task CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) => await TryConnectAsync(connection).ConfigureAwait(false); - var result = connection.ConnectionState switch - { - NatsConnectionState.Open => HealthCheckResult.Healthy(), - NatsConnectionState.Connecting or NatsConnectionState.Reconnecting => HealthCheckResult.Degraded(), - NatsConnectionState.Closed => await TryConnectAsync(connection).ConfigureAwait(false), - _ => new HealthCheckResult(context.Registration.FailureStatus) - }; - - return result; - } - private static async Task TryConnectAsync(INatsConnection natsConnection) { try