chore: bootstrap repository with governance docs
Initialize git, add Apache-2.0 LICENSE, .gitattributes (LF line endings), AGENTS.md (entry points, stack, discovery order, baseline checks), RUNBOOK.md (dev boot, prod deploy with overlay, ingestion, failures, rollback, scaling notes), .env.prod.example with rotated credential placeholders, and dev-only warnings on .env.example. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
0
app/workers/__init__.py
Normal file
0
app/workers/__init__.py
Normal file
28
app/workers/celery_app.py
Normal file
28
app/workers/celery_app.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""Celery application instance."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from celery import Celery
|
||||
|
||||
from app.config import settings
|
||||
from app.logging_config import configure_logging
|
||||
|
||||
configure_logging()
|
||||
|
||||
celery_app = Celery(
|
||||
"legacyhub",
|
||||
broker=settings.redis_url,
|
||||
backend=settings.redis_url,
|
||||
include=["app.workers.tasks"],
|
||||
)
|
||||
|
||||
celery_app.conf.update(
|
||||
task_acks_late=True,
|
||||
task_reject_on_worker_lost=True,
|
||||
task_track_started=True,
|
||||
worker_prefetch_multiplier=1,
|
||||
task_time_limit=settings.max_document_timeout_seconds * 4,
|
||||
task_soft_time_limit=settings.max_document_timeout_seconds * 3,
|
||||
timezone="UTC",
|
||||
enable_utc=True,
|
||||
)
|
||||
22
app/workers/tasks.py
Normal file
22
app/workers/tasks.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""Celery tasks - thin wrappers over pipeline functions."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
|
||||
from celery.utils.log import get_task_logger
|
||||
|
||||
from app.workers.celery_app import celery_app
|
||||
|
||||
logger = get_task_logger(__name__)
|
||||
|
||||
|
||||
@celery_app.task(name="legacyhub.process_document", bind=True, max_retries=2, default_retry_delay=30)
|
||||
def process_document(self, document_id: str, run_id: str | None = None) -> dict:
|
||||
from app.ingestion.pipeline import process_document_id
|
||||
|
||||
try:
|
||||
return process_document_id(uuid.UUID(document_id), uuid.UUID(run_id) if run_id else None)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
logger.exception("worker.process_failed", extra={"document_id": document_id})
|
||||
raise self.retry(exc=exc) from exc
|
||||
Reference in New Issue
Block a user