53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
"""ARQ worker configuration and entrypoint."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from typing import Any
|
|
|
|
from arq.connections import RedisSettings
|
|
|
|
from app.config import get_settings
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def _get_redis_settings() -> RedisSettings:
|
|
"""Get Redis settings from app config."""
|
|
settings = get_settings()
|
|
return RedisSettings.from_dsn(settings.redis_url)
|
|
|
|
|
|
async def on_startup(ctx: dict[str, Any]) -> None:
|
|
"""Called when worker starts."""
|
|
logger.info("ARQ worker starting...")
|
|
|
|
|
|
async def on_shutdown(ctx: dict[str, Any]) -> None:
|
|
"""Called when worker shuts down."""
|
|
logger.info("ARQ worker shutting down...")
|
|
|
|
|
|
class WorkerSettings:
|
|
"""ARQ worker settings.
|
|
|
|
functions must be dotted module paths to async callables,
|
|
e.g. 'app.plugins.builtins.unified_search.jobs.reindex'
|
|
"""
|
|
functions = [
|
|
"app.plugins.builtins.unified_search.jobs.index_mails",
|
|
"app.plugins.builtins.unified_search.jobs.index_file",
|
|
"app.plugins.builtins.unified_search.jobs.index_contact",
|
|
"app.plugins.builtins.unified_search.jobs.index_company",
|
|
"app.plugins.builtins.unified_search.jobs.index_event",
|
|
"app.plugins.builtins.unified_search.jobs.reindex",
|
|
"app.plugins.builtins.unified_search.jobs.embedding_batch",
|
|
"app.plugins.builtins.ai_proactive.jobs.deep_analysis",
|
|
]
|
|
redis_settings = _get_redis_settings()
|
|
on_startup = on_startup
|
|
on_shutdown = on_shutdown
|
|
max_jobs = 10
|
|
job_timeout = 300
|
|
queue_name = "arq:queue"
|