Skip to content

Commit

Permalink
Undo changes
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlyJazz committed Nov 19, 2023
1 parent 7ada304 commit 7e1c432
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions auth-microservice/app/api/health.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import asyncio
import socket

from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession
from starlette.responses import Response
from sqlalchemy.sql import text

from app.api.deps import get_session

router = APIRouter(prefix="/health", tags=["Health"])


@router.get("/", status_code=200)
async def health(session: AsyncSession = Depends(get_session)):
try:
await asyncio.wait_for(session.execute(text("SELECT 1")), timeout=1)
except (asyncio.TimeoutError, socket.gaierror):
return Response(status_code=503)
return Response(status_code=200)

0 comments on commit 7e1c432

Please sign in to comment.