Skip to content

Commit

Permalink
fix: use StatusServiceUnavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
jibon57 committed Dec 27, 2024
1 parent 98474cd commit 554e1f5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/controllers/health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ import (
func HandleHealthCheck(c *fiber.Ctx) error {
db, err := config.GetConfig().DB.DB()
if err != nil {
return c.Status(fiber.StatusInternalServerError).SendString("DB connection error")
return c.Status(fiber.StatusServiceUnavailable).SendString("DB connection error")
}
err = db.Ping()
if err != nil {
return c.Status(fiber.StatusInternalServerError).SendString("DB connection error")
return c.Status(fiber.StatusServiceUnavailable).SendString("DB connection error")
}

_, err = config.GetConfig().RDS.Ping(context.Background()).Result()
if err != nil {
return c.Status(fiber.StatusInternalServerError).SendString("Redis connection error")
return c.Status(fiber.StatusServiceUnavailable).SendString("Redis connection error")
}

if !config.GetConfig().NatsConn.IsConnected() {
return c.Status(fiber.StatusInternalServerError).SendString("Nats connection error")
return c.Status(fiber.StatusServiceUnavailable).SendString("Nats connection error")
}

return c.Status(fiber.StatusOK).SendString("Healthy")
Expand Down

0 comments on commit 554e1f5

Please sign in to comment.