pub async fn run_in_container_stream(
image_name: &str,
run_cmd: &str,
source: &str,
ext: &str,
limits: ResourceLimits,
tx: Sender<OutputChunk>,
) -> Result<(Option<i64>, String, String, bool, bool), Error>Expand description
流式执行:与 run_in_container 相同的容器生命周期与清理(ContainerGuard),
但边读日志流边推 chunk 到 tx,同时保留完整 buffer 供调用方回填 EXEC_TASKS。
与 run_in_container 的差异:
- 日志循环里每块 chunk 既
tx.send推流,也 append 到本地 buffer。 - 用
tokio::select!在日志读取中并发等待tx关闭——客户端断开(SSE 关闭) →tx所有 Sender drop →rx返回 None → 中止读取。 - 终态推
OutputChunk::Done后 return。
返回完整 buffer(exit_code / stdout / stderr / oom / timed_out),供调用方写 EXEC_TASKS, 让轮询兜底路径(get_exec_result)也能拿到完整结果。