Replace the 1095-line monolithic SearchService with a thin facade that delegates to SearchOrchestrator. Split the implementation into three focused modules: - search_orchestrator.py: request parsing, provider coordination, and response construction - search_providers.py: per-source execution, progress callbacks, and async task creation - search_cache.py: timestamping and stable cache stamping for results Add unit tests for the new components in tests/test_search_service_components.py. Preserve the existing HTTP route behavior by keeping SearchService.search_sources as the stable route-facing API.
16 lines
538 B
Python
16 lines
538 B
Python
"""Facade for remote model source search."""
|
|
|
|
from ..routes.context import RouteContext
|
|
from .search_orchestrator import SearchOrchestrator
|
|
|
|
|
|
class SearchService:
|
|
"""Keep the route-facing search API stable while delegating orchestration."""
|
|
|
|
def __init__(self, context: RouteContext):
|
|
self._orchestrator = SearchOrchestrator(context)
|
|
|
|
async def search_sources(self, request):
|
|
"""Search configured sources and return the HTTP response payload."""
|
|
return await self._orchestrator.search_sources(request)
|