CadHubManage/app/api/v1/plugin_callbacks.py
sladro b19ef1467a feat: Implement CAD batch processing framework with plugin callback handling
- Added configuration for file storage and software plugins in `software_config.yaml`.
- Created core components for batch processing including `CadBatchManager`, `CadTaskRouter`, and `SerialBatchExecutor`.
- Implemented plugin callback handling with `PluginCallbackRegistry` and HTTP client for task submission.
- Developed API endpoint for receiving plugin callbacks in `plugin_callbacks.py`.
- Enhanced data models for batch processing including `BatchJob`, `BatchItem`, and callback payloads.
- Introduced WebSocket support for real-time updates on batch processing status.
- Added comprehensive tests for routing, callback API, and serial executor behavior.
- Documented the implementation plan and core execution rules in `cad-batch-plan.md`.
2026-03-01 08:48:10 +08:00

24 lines
719 B
Python

from fastapi import APIRouter, HTTPException, status
from app.core.cad_batch_manager import cad_batch_manager
from app.models.cad_batch import PluginCallbackPayload
router = APIRouter()
@router.post("/plugin-callbacks/task-result")
async def plugin_task_result(payload: PluginCallbackPayload):
if not cad_batch_manager.validate_callback_token(payload.software_id, payload.token):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Invalid callback token",
)
accepted = await cad_batch_manager.handle_plugin_callback(payload)
return {
"success": True,
"accepted": accepted,
"execution_id": payload.execution_id,
}