* 开始任务
(id: string)
| 385 | * 开始任务 |
| 386 | */ |
| 387 | public startTask(id: string): WorkflowTask { |
| 388 | // 检查并发任务限制 |
| 389 | const inProgressTasks = this.getTasksByStatus('in-progress'); |
| 390 | if (inProgressTasks.length >= this.config.maxConcurrentTasks) { |
| 391 | throw new Error(`已达到最大并发任务数限制: ${this.config.maxConcurrentTasks}`); |
| 392 | } |
| 393 | |
| 394 | const task = this.getTask(id); |
| 395 | if (!task) { |
| 396 | throw new Error(`任务不存在: ${id}`); |
| 397 | } |
| 398 | |
| 399 | // 检查依赖 |
| 400 | const executableTasks = this.getExecutableTasks(); |
| 401 | if (!executableTasks.find(t => t.id === id)) { |
| 402 | throw new Error(`任务有未完成的依赖,无法开始: ${id}`); |
| 403 | } |
| 404 | |
| 405 | return this.updateTask(id, { status: 'in-progress' }); |
| 406 | } |
| 407 | |
| 408 | /** |
| 409 | * 完成任务 |
nothing calls this directly
no test coverage detected