Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/app/interfaces/api/v1/endpoints/debug/resources.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from typing import Annotated, Dict
from typing import Annotated

from fastapi import APIRouter, Body, Request
from fastapi.responses import JSONResponse
from starlette.status import HTTP_200_OK, HTTP_400_BAD_REQUEST

from src.app.application.container import container as services_container
from src.app.interfaces.api.v1.endpoints.debug.schemas.req_schemas import MessageReq
from src.app.config.settings import settings
from src.app.infrastructure.messaging.mq_client import mq_client
from src.app.interfaces.api.v1.endpoints.debug.schemas.req_schemas import MessageReq

router = APIRouter(prefix="/debug")

Expand Down Expand Up @@ -41,7 +44,10 @@ async def send_message(
@router.get("/health-check/", status_code=200)
async def health_check(
request: Request,
) -> Dict[str, str]:
) -> JSONResponse:
is_healthy = await services_container.common_service.is_healthy()
status = "OK" if is_healthy else "NOT OK"
return {"status": status}
status_code = HTTP_200_OK if is_healthy else HTTP_400_BAD_REQUEST
resp = JSONResponse(content={"status": status}, status_code=status_code)

return resp
2 changes: 1 addition & 1 deletion src/app/interfaces/grpc/services/debug_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ async def SendMessage(self, request, context) -> pb2.MessageResp: # type: ignor

async def HealthCheck(self, request, context) -> pb2.HealthCheckResp: # type: ignore
is_healthy = await services_container.common_service.is_healthy()
status = "OK" if is_healthy else "NOT OK"
status = "SERVING" if is_healthy else "NOT_SERVING"
return pb2.HealthCheckResp(status=status) # type: ignore