feat: Implement background extraction processor with concurrency control
- Added `ExtractionProcessor` class to handle extraction queue processing in the background. - Implemented methods for starting, stopping, and queuing extractions with concurrency limits. - Integrated logging for monitoring the processor's status and actions. - Created tests for the extraction processor to ensure functionality and error handling. test: Add unit tests for extraction API endpoints - Created tests for successful extraction creation, authentication checks, and processor status retrieval. - Ensured proper responses for authenticated and unauthenticated requests. test: Implement unit tests for extraction repository - Added tests for creating, retrieving, and updating extractions in the repository. - Mocked database interactions to validate repository behavior without actual database access. test: Add comprehensive tests for extraction service - Developed tests for extraction creation, service detection, and sound record creation. - Included tests for handling duplicate extractions and invalid URLs. test: Add unit tests for extraction background processor - Created tests for the `ExtractionProcessor` class to validate its behavior under various conditions. - Ensured proper handling of extraction queuing, processing, and completion callbacks. fix: Update OAuth service tests to use AsyncMock - Modified OAuth provider tests to use `AsyncMock` for mocking asynchronous HTTP requests.
This commit is contained in:
@@ -9,6 +9,7 @@ from app.api import api_router
|
||||
from app.core.database import init_db
|
||||
from app.core.logging import get_logger, setup_logging
|
||||
from app.middleware.logging import LoggingMiddleware
|
||||
from app.services.extraction_processor import extraction_processor
|
||||
from app.services.socket import socket_manager
|
||||
|
||||
|
||||
@@ -22,9 +23,17 @@ async def lifespan(_app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
await init_db()
|
||||
logger.info("Database initialized")
|
||||
|
||||
# Start the extraction processor
|
||||
await extraction_processor.start()
|
||||
logger.info("Extraction processor started")
|
||||
|
||||
yield
|
||||
|
||||
logger.info("Shutting down application")
|
||||
|
||||
# Stop the extraction processor
|
||||
await extraction_processor.stop()
|
||||
logger.info("Extraction processor stopped")
|
||||
|
||||
|
||||
def create_app():
|
||||
|
||||
Reference in New Issue
Block a user