This commit is contained in:
anlicheng 2026-05-09 15:49:37 +08:00
parent 1a6820a8b4
commit f9f7ea346b
3 changed files with 25 additions and 6 deletions

View File

@ -157,7 +157,7 @@ json_error(ErrCode, ErrMessage) when is_integer(ErrCode), is_binary(ErrMessage)
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
|--------|------|------|------| |--------|------|------|------|
| uuid | binary (string) | ✅ | 主机唯一标识符 | | uuid | binary (string) | ✅ | 主机唯一标识符 |
| task_id | integer | ✅ | 任务 ID | | task_id | integer | ✅ | 任务 ID,和 uuid 一起作为部署任务唯一标识 |
| config | map | ✅ | 部署配置内容 | | config | map | ✅ | 部署配置内容 |
#### 响应参数 #### 响应参数
@ -255,13 +255,16 @@ json_error(ErrCode, ErrMessage) when is_integer(ErrCode), is_binary(ErrMessage)
#### 示例响应 #### 示例响应
```json ```json
{ {
"result": { "data": "ok"
"task_id": 1001,
"status": "deployed"
}
} }
``` ```
部署过程实时日志通过 SSE 获取:
```http
GET /event_stream?uuid=qbxmjyzrkpntfgswaevodhluicqzxplkm&task_id=1
```
#### 错误响应 #### 错误响应
```json ```json
{ {

View File

@ -94,11 +94,19 @@ HTTP body 必须是 JSON object。`http_protocol` 会使用 `json:decode/1` 解
| 字段 | JSON 类型 | 必填 | 说明 | | 字段 | JSON 类型 | 必填 | 说明 |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| `uuid` | string | 是 | 目标 efka 所属主机 UUID。服务端用它查找 `iot_host` 进程,不会下发到 efka。 | | `uuid` | string | 是 | 目标 efka 所属主机 UUID。服务端用它查找 `iot_host` 进程,不会下发到 efka。 |
| `task_id` | non-negative integer | 是 | 部署任务 ID。会进入内部命令的 `task_id` 字段,用于关联部署结果和部署日志流。 | | `task_id` | non-negative integer | 是 | 部署任务 ID。会进入内部命令的 `task_id` 字段,用于关联部署结果和部署日志流。`iot` 内部使用 `{uuid, task_id}` 作为任务唯一标识。 |
| `config` | object | 是 | 容器创建配置。会被校验并转换成内部部署参数 map。 | | `config` | object | 是 | 容器创建配置。会被校验并转换成内部部署参数 map。 |
顶层没有 `timeout` 字段。当前 HTTP handler 等待 efka command response 的超时时间固定为 10 秒。 顶层没有 `timeout` 字段。当前 HTTP handler 等待 efka command response 的超时时间固定为 10 秒。
部署过程的实时反馈通过 SSE 读取:
```http
GET /event_stream?uuid=<host_uuid>&task_id=<task_id>
```
`/container/deploy` 收到合法请求后会先在 `iot` 内部创建或复用 `{uuid, task_id}` 对应的任务进程,然后再向 `efka` 下发部署命令。SSE handler 订阅同一个任务进程;该进程会缓存最近的部署事件,支持多个页面同时订阅,并在收到 efka 的 close 事件后关闭 SSE。
## 4. config 参数 ## 4. config 参数
### 必填字段 ### 必填字段

View File

@ -207,6 +207,14 @@ ok
}}} }}}
``` ```
`task_event` 本身不携带 `uuid``iot` 在接收该消息时使用当前已鉴权 `ssl_channel` 绑定的 host UUID把事件路由到内部任务进程 `{UUID, TaskId}`。HTTP 页面通过 SSE 订阅时也必须使用同一组参数:
```http
GET /event_stream?uuid=<host_uuid>&task_id=<task_id>
```
`iot` 会为每个 `{UUID, TaskId}` 维护一个独立的任务进程,用于缓存最近的部署日志、支持多个 SSE listener并在收到 close 事件后结束事件流。
### iot -> efka: pub ### iot -> efka: pub
```erlang ```erlang