M-10-async-task-worker.json
2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
"id": "M-10",
"name": "异步任务处理服务",
"fileKey": "async-task-worker",
"desc": "Celery Worker 实现的后台异步任务处理服务,消费 Celery 队列中的 LLM 调用任务",
"apis": [
{
"method": "POST",
"path": "/api/v1/internal/tasks/process",
"name": "处理异步任务",
"description": "处理异步 LLM 调用:加载配置→调用适配器→写入结果→更新任务状态",
"params": [
{"name": "task_id", "in": "body", "type": "string", "required": true, "desc": "任务 ID"},
{"name": "celery_task_id", "in": "body", "type": "string", "required": true, "desc": "Celery 任务 ID"}
],
"responses": [
{"code": 200, "desc": "处理完成", "schema": ""},
{"code": 500, "desc": "处理失败", "schema": ""}
],
"backend": [
{"tag": "receive", "text": "接收 POST /api/v1/internal/tasks/process 请求"},
{"tag": "query", "text": "从数据库表按条件查询记录"},
{"tag": "validate", "text": "验证记录存在和修改后的字段"},
{"tag": "write", "text": "更新数据库表记录"},
{"tag": "return", "text": "返回操作结果"}
]
},
{
"method": "POST",
"path": "/api/v1/internal/tasks/retry",
"name": "任务失败重试",
"description": "任务失败自动重试(可配置最大重试次数)",
"params": [
{"name": "task_id", "in": "body", "type": "string", "required": true, "desc": "任务 ID"}
],
"responses": [
{"code": 200, "desc": "重试已触发", "schema": ""},
{"code": 400, "desc": "已达最大重试次数", "schema": ""}
],
"backend": [
{"tag": "receive", "text": "接收 POST /api/v1/internal/tasks/retry 请求"},
{"tag": "validate", "text": "验证请求参数"},
{"tag": "query", "text": "从数据库表按条件查询记录"},
{"tag": "return", "text": "返回操作结果"}
]
},
{
"method": "POST",
"path": "/api/v1/internal/tasks/batch-process",
"name": "批量处理",
"description": "扫描待处理任务列表,批量提交到线程池并行执行",
"params": [
{"name": "batch_size", "in": "body", "type": "integer", "required": false, "desc": "批量大小"}
],
"responses": [
{"code": 200, "desc": "批量处理完成", "schema": "{processed_count}"}
],
"backend": [
{"tag": "receive", "text": "接收 POST /api/v1/internal/tasks/batch-process 请求"},
{"tag": "validate", "text": "验证分页和筛选参数"},
{"tag": "query", "text": "从数据库表按条件查询记录"},
{"tag": "return", "text": "返回分页结果"}
]
}
]
}