mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-06 22:12:12 +02:00
Scoped codemod over surfsense_backend/app (excluding routes/, Wave E): renames search_space_id -> workspace_id, search_space -> workspace, SearchSpace -> Workspace across services, utils, tasks, agents, gateway, event_bus, notifications, podcasts, automations, observability params, and prompt .md files. Also flips the camelCase payload key searchSpaceId -> workspaceId (no backend reader; hard cutover). Preserved carve-outs (verbatim): Celery task names "delete_search_space_background" and "ai_sort_search_space" (wire names), and the OTel/metric key "search_space.id" (dashboards depend on it). Enum values 'SEARCH_SPACE' and SearchSourceConnector untouched.
56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
"""Task dispatcher abstraction for background document processing.
|
|
|
|
Decouples the upload endpoint from Celery so tests can swap in a
|
|
synchronous (inline) implementation that needs only PostgreSQL.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Protocol
|
|
|
|
|
|
class TaskDispatcher(Protocol):
|
|
async def dispatch_file_processing(
|
|
self,
|
|
*,
|
|
document_id: int,
|
|
temp_path: str,
|
|
filename: str,
|
|
workspace_id: int,
|
|
user_id: str,
|
|
use_vision_llm: bool = False,
|
|
processing_mode: str = "basic",
|
|
) -> None: ...
|
|
|
|
|
|
class CeleryTaskDispatcher:
|
|
"""Production dispatcher — fires Celery tasks via Redis broker."""
|
|
|
|
async def dispatch_file_processing(
|
|
self,
|
|
*,
|
|
document_id: int,
|
|
temp_path: str,
|
|
filename: str,
|
|
workspace_id: int,
|
|
user_id: str,
|
|
use_vision_llm: bool = False,
|
|
processing_mode: str = "basic",
|
|
) -> None:
|
|
from app.tasks.celery_tasks.document_tasks import (
|
|
process_file_upload_with_document_task,
|
|
)
|
|
|
|
process_file_upload_with_document_task.delay(
|
|
document_id=document_id,
|
|
temp_path=temp_path,
|
|
filename=filename,
|
|
workspace_id=workspace_id,
|
|
user_id=user_id,
|
|
use_vision_llm=use_vision_llm,
|
|
processing_mode=processing_mode,
|
|
)
|
|
|
|
|
|
async def get_task_dispatcher() -> TaskDispatcher:
|
|
return CeleryTaskDispatcher()
|