fix: Health check Redis 상태 실제 PING 체크로 변경 (#156) #157
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user