исправленная версия с dlq

This commit is contained in:
2026-11-14 01:57:24 +03:00
parent 651d838778
commit b5b7ab204b
3 changed files with 409 additions and 210 deletions
+1 -12
View File
@@ -9,8 +9,7 @@ from fastapi.responses import JSONResponse
from fastapi.exceptions import RequestValidationError
from starlette.exceptions import HTTPException as StarletteHTTPException
from app.routers import auth, chats, attachments
from app.database import AsyncSessionLocal
from app.broker import relay_outbox
from app.broker import run_relay
logger = logging.getLogger(__name__)
@@ -22,16 +21,6 @@ async def lifespan(app: FastAPI):
# Останавливаем при завершении
task.cancel()
async def run_relay():
while True:
try:
async with AsyncSessionLocal() as db:
await relay_outbox(db)
await asyncio.sleep(1) # Проверяем outbox каждую секунду
except Exception as e:
logger.error(f"Relay loop crashed: {e}")
await asyncio.sleep(5)
app = FastAPI(lifespan=lifespan)
app.include_router(auth.router)