fix: Health check Redis 상태를 실제 PING 체크로 변경 (#156)
- not_configured 하드코딩 제거 - RedisConnection 주입 후 PingAsync()로 실제 연결 상태 확인 - 응답에 latency 포함 Closes #156
This commit is contained in:
parent
bbcb770b2d
commit
c63a61bf6a
|
|
@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
|
||||||
using Swashbuckle.AspNetCore.Annotations;
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
using SPMS.Domain.Common;
|
using SPMS.Domain.Common;
|
||||||
using SPMS.Infrastructure;
|
using SPMS.Infrastructure;
|
||||||
|
using SPMS.Infrastructure.Caching;
|
||||||
using SPMS.Infrastructure.Messaging;
|
using SPMS.Infrastructure.Messaging;
|
||||||
|
|
||||||
namespace SPMS.API.Controllers;
|
namespace SPMS.API.Controllers;
|
||||||
|
|
@ -15,15 +16,18 @@ namespace SPMS.API.Controllers;
|
||||||
public class PublicController : ControllerBase
|
public class PublicController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly AppDbContext _dbContext;
|
private readonly AppDbContext _dbContext;
|
||||||
|
private readonly RedisConnection _redisConnection;
|
||||||
private readonly RabbitMQConnection _rabbitConnection;
|
private readonly RabbitMQConnection _rabbitConnection;
|
||||||
private readonly RabbitMQInitializer _rabbitInitializer;
|
private readonly RabbitMQInitializer _rabbitInitializer;
|
||||||
|
|
||||||
public PublicController(
|
public PublicController(
|
||||||
AppDbContext dbContext,
|
AppDbContext dbContext,
|
||||||
|
RedisConnection redisConnection,
|
||||||
RabbitMQConnection rabbitConnection,
|
RabbitMQConnection rabbitConnection,
|
||||||
RabbitMQInitializer rabbitInitializer)
|
RabbitMQInitializer rabbitInitializer)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
|
_redisConnection = redisConnection;
|
||||||
_rabbitConnection = rabbitConnection;
|
_rabbitConnection = rabbitConnection;
|
||||||
_rabbitInitializer = rabbitInitializer;
|
_rabbitInitializer = rabbitInitializer;
|
||||||
}
|
}
|
||||||
|
|
@ -47,8 +51,18 @@ public class PublicController : ControllerBase
|
||||||
allHealthy = false;
|
allHealthy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Redis 연결 확인 (Phase 3-2에서 구현 예정)
|
// 2. Redis 연결 확인
|
||||||
checks["redis"] = new { status = "not_configured" };
|
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 연결 확인
|
// 3. RabbitMQ 연결 확인
|
||||||
var rabbitConnected = _rabbitConnection.IsConnected;
|
var rabbitConnected = _rabbitConnection.IsConnected;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user