feat: перенос структуры приложения из четвертой лабы

This commit is contained in:
Ильяс
2026-11-07 16:51:38 +03:00
parent 276dbdad8a
commit 7cfc6d40a6
28 changed files with 3749 additions and 1 deletions
+31
View File
@@ -0,0 +1,31 @@
from __future__ import annotations
from fastapi import APIRouter, status
from starlette.exceptions import HTTPException as StarletteHTTPException
from app.schemas import HealthResponse
from app.storage import storage
router = APIRouter(tags=["health"])
@router.get(
"/health/live", response_model=HealthResponse, status_code=status.HTTP_200_OK
)
async def health_live() -> HealthResponse:
"""Проверка жизни процесса (Liveness)."""
return HealthResponse(status="ok")
@router.get(
"/health/ready", response_model=HealthResponse, status_code=status.HTTP_200_OK
)
async def health_ready() -> HealthResponse:
"""Проверка готовности сервиса и его зависимостей (Readiness)."""
is_ready = await storage.check_health()
if not is_ready:
raise StarletteHTTPException(
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
detail="Сервис или его хранилища недоступны",
)
return HealthResponse(status="ok")