lab3: nginx, replicas, idempotency, tests

This commit is contained in:
2026-11-06 17:23:38 +03:00
commit 46c829b730
96 changed files with 206384 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
from fastapi import APIRouter
from fastapi import HTTPException
from sqlalchemy import text
from app.database import async_session_maker
from app.redis_client import redis_client
router = APIRouter(tags=["health"])
@router.get("/health/live")
def live():
return {"status": "ok"}
@router.get("/health/ready")
async def ready():
try:
async with async_session_maker() as session:
await session.execute(text("SELECT 1"))
await redis_client.ping()
return {"status": "ok"}
except Exception:
raise HTTPException(status_code=503, detail="unavailable")
@router.get("/")
def home():
return {
"service": "MTUSI Messenger",
"version": "1.1.0",
"docs": "/docs",
}