Files
anti-plagiarism/services/api/app/core/celery_app.py
jze9 7758315632 feat: initial microservices project structure
Services:
- api: FastAPI gateway with JWT auth, async endpoints, WebSocket
- worker-gpu: CUDA sentence-transformers, FAISS IVFFlat, Ollama LLM
- worker-indexer: Winnowing+MinHash plagiarism detection, PDF/DOCX extraction
- worker-notifier: SMTP email notifications
- worker-gost: GOST 7.1-2003 and GOST R 7.0.5-2008 formatting

Infrastructure:
- docker-compose.yml (production) + docker-compose.dev.yml (hot reload)
- Nginx reverse proxy + WebSocket support
- PostgreSQL 16 with Alembic migrations
- Elasticsearch 8 with Russian/English analyzers
- MinIO, RabbitMQ, Redis, Ollama

Frontend:
- React 18 + Vite + TypeScript + TailwindCSS + Zustand + React Query v5
- 9 pages: Home, Search, Cabinet, Task, Check, Bibliography, Pricing, Login, Register

Scripts:
- Parser stubs: OpenAlex, КиберЛенинка, arXiv (Phase 0 - to be filled)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-24 19:42:39 +05:00

40 lines
1.3 KiB
Python

"""Celery приложение для API-диспатчера. Только определение — задачи находятся в воркерах."""
from celery import Celery
from app.config import settings
celery_app = Celery(
"api_dispatcher",
broker=settings.RABBITMQ_URL,
backend=settings.REDIS_URL,
)
celery_app.conf.update(
task_serializer="json",
result_serializer="json",
accept_content=["json"],
timezone="Europe/Moscow",
enable_utc=True,
task_track_started=True,
# Маршрутизация задач по очередям воркеров
task_routes={
"gpu.*": {"queue": "queue.gpu"},
"index.*": {"queue": "queue.index"},
"notify.*": {"queue": "queue.notify"},
"gost.*": {"queue": "queue.gost"},
},
# Настройки очередей
task_queues={
"queue.gpu": {"exchange": "queue.gpu", "routing_key": "queue.gpu"},
"queue.index": {"exchange": "queue.index", "routing_key": "queue.index"},
"queue.notify": {"exchange": "queue.notify", "routing_key": "queue.notify"},
"queue.gost": {"exchange": "queue.gost", "routing_key": "queue.gost"},
},
# Результаты хранить 24 часа
result_expires=86400,
# Повторные попытки
task_acks_late=True,
task_reject_on_worker_lost=True,
)