"""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, )