From c63a61bf6a26c6fdbe87419231e3f7318a33ef6f Mon Sep 17 00:00:00 2001 From: SEAN Date: Wed, 11 Feb 2026 10:49:47 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20Health=20check=20Redis=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=EB=A5=BC=20=EC=8B=A4=EC=A0=9C=20PING=20=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20(#156)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - not_configured 하드코딩 제거 - RedisConnection 주입 후 PingAsync()로 실제 연결 상태 확인 - 응답에 latency 포함 Closes #156 --- SPMS.API/Controllers/PublicController.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/SPMS.API/Controllers/PublicController.cs b/SPMS.API/Controllers/PublicController.cs index 28dfaea..c5521f1 100644 --- a/SPMS.API/Controllers/PublicController.cs +++ b/SPMS.API/Controllers/PublicController.cs @@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore; using Swashbuckle.AspNetCore.Annotations; using SPMS.Domain.Common; using SPMS.Infrastructure; +using SPMS.Infrastructure.Caching; using SPMS.Infrastructure.Messaging; namespace SPMS.API.Controllers; @@ -15,15 +16,18 @@ namespace SPMS.API.Controllers; public class PublicController : ControllerBase { private readonly AppDbContext _dbContext; + private readonly RedisConnection _redisConnection; private readonly RabbitMQConnection _rabbitConnection; private readonly RabbitMQInitializer _rabbitInitializer; public PublicController( AppDbContext dbContext, + RedisConnection redisConnection, RabbitMQConnection rabbitConnection, RabbitMQInitializer rabbitInitializer) { _dbContext = dbContext; + _redisConnection = redisConnection; _rabbitConnection = rabbitConnection; _rabbitInitializer = rabbitInitializer; } @@ -47,8 +51,18 @@ public class PublicController : ControllerBase allHealthy = false; } - // 2. Redis 연결 확인 (Phase 3-2에서 구현 예정) - checks["redis"] = new { status = "not_configured" }; + // 2. Redis 연결 확인 + try + { + var db = await _redisConnection.GetDatabaseAsync(); + var pong = await db.PingAsync(); + checks["redis"] = new { status = "healthy", latency = $"{pong.TotalMilliseconds:F1}ms" }; + } + catch (Exception ex) + { + checks["redis"] = new { status = "unhealthy", error = ex.Message }; + allHealthy = false; + } // 3. RabbitMQ 연결 확인 var rabbitConnected = _rabbitConnection.IsConnected;