feat: реализация второй лабы по тз

This commit is contained in:
Enterxx2
2026-10-11 18:14:20 +03:00
parent a6c74c9bb0
commit ea2b432a22
100 changed files with 3416 additions and 428 deletions
+11 -3
View File
@@ -1,7 +1,8 @@
from fastapi import APIRouter, Request, status
from fastapi import APIRouter, Depends, Request, status
from domain import HealthSchema
from domain.errors import UnavailableError
from infrastructure.dependencies import DatabasePoolManager, get_database
health_router = APIRouter(prefix="/health", tags=["Health"])
@@ -21,8 +22,15 @@ async def liveness() -> HealthSchema:
status_code=status.HTTP_200_OK,
response_model=HealthSchema,
)
async def readiness(request: Request) -> HealthSchema:
"""Хранилище создано и приложение не завершается"""
async def readiness(
request: Request, database: DatabasePoolManager = Depends(get_database)
) -> HealthSchema:
"""
Приложение не завершается и PostgreSQL отвечает. Valkey не критичен:
без него сессии читаются из PostgreSQL, поэтому он не влияет на готовность.
"""
if not getattr(request.app.state, "is_ready", False):
raise UnavailableError()
if not await database.check():
raise UnavailableError("бд недоступна")
return HealthSchema()