refactor(scheduler): 统一异步任务调度架构

核心变更:
- 统一第三方接口架构:所有服务走 PlatformGateway(call_sync/submit_task/query_task/handle_webhook)
- 视频生成(Vidu 对口型)纳入 Async Engine,与 script/subtitle/tts 统一为 POST /tasks/{task_type} 模式
- 新增 VideoHandler、TTSHandler,完善 ScriptHandler/SubtitleHandler
- PlatformGateway 生成 internal_task_id,建立 Redis 双向映射,callback 场景传入 Async Engine task_id 保证映射一致
- SlotManager 新增 acquire_ctx 上下文管理器,所有 Handler 统一使用
- ViduAdapter 状态映射归一化(normalize_state/denormalize_state)
- 移除 ViduService Semaphore 和 tenacity 重试,并发控制完全交予 SlotManager
- nonce 防重放下沉到 CallbackCapable 协议
- Service 层错误统一为 PlatformError,路由层错误信息脱敏
- 废弃 /voice/lip-sync,清理 vidu.py 遗留路由

Bug 修复:
- VideoHandler 轮询阶段后添加 continue,防止已提交任务重复创建
- voice.py synthesize_to_file 变量名冲突(request vs request_body)
- PlatformGateway.submit_task 空 data 防护
- ScriptHandler 动态导入 asyncio 改为模块级导入
- SubtitleHandler 完成时补充 progress=100

文档:
- 更新 AGENTS.md 核心功能、运行时架构、异步调度描述
This commit is contained in:
小鱼开发
2026-05-05 20:53:18 +08:00
parent f32c1c7703
commit 30536276ba
24 changed files with 1653 additions and 1367 deletions
+2 -2
View File
@@ -73,14 +73,14 @@ async def polish_content(request: PolishRequest):
logger.warning(f"[Polish] 润色失败: {e}")
return success_response(
code=500,
message=str(e),
message="润色失败,请检查输入内容后重试",
data=None,
)
except Exception as e:
logger.error(f"[Polish] 润色异常: {e}")
return success_response(
code=500,
message=f"{type_name}润色失败: {str(e)}",
message=f"{type_name}润色失败,请稍后重试",
data=None,
)