docs: annotate Foundry source and deployment lifecycle in Chinese [skip ci]
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// Canonical 模型 NDJSON 传输:从已一致捕获的内存模型编码,不边读库边向慢客户端发送。
|
||||
package platform
|
||||
|
||||
import (
|
||||
@@ -11,6 +12,7 @@ const modelStreamType = "application/vnd.foundry.canvas-model+ndjson;version=1"
|
||||
// The caller captures a coherent model while holding the workspace lock, then
|
||||
// releases its transaction before writing. A slow reader must not hold a writer.
|
||||
// This streams transfer/encoding; it does not stream database row acquisition.
|
||||
// writeCanvasModelStream 发送 header、elements 批次和 complete,统一 token/sequence 供客户端检测截断或混流。
|
||||
func writeCanvasModelStream(ctx context.Context, w http.ResponseWriter, model canvasModel) {
|
||||
token := newModelID()
|
||||
if token == "" {
|
||||
@@ -19,6 +21,7 @@ func writeCanvasModelStream(ctx context.Context, w http.ResponseWriter, model ca
|
||||
}
|
||||
view := model.view(nil)
|
||||
// A count covers direct members only; an empty canvas is explicit too.
|
||||
// 头部显式声明每画布直接元素数、总数与身份 owner,空画布也必须覆盖。
|
||||
counts := map[string]int{}
|
||||
owners := map[string]string{}
|
||||
for _, canvas := range view.Canvases {
|
||||
@@ -45,6 +48,7 @@ func writeCanvasModelStream(ctx context.Context, w http.ResponseWriter, model ca
|
||||
const maxBytes = 64 * 1024 * 1024
|
||||
sequence, total := 0, 0
|
||||
started := false
|
||||
// 每行/总字节/记录数均有预算;开始前可写结构化错误,开始后只能停流让缺 complete 表示失败。
|
||||
write := func(value response) bool {
|
||||
if ctx.Err() != nil {
|
||||
return false
|
||||
@@ -78,6 +82,7 @@ func writeCanvasModelStream(ctx context.Context, w http.ResponseWriter, model ca
|
||||
}
|
||||
batch := []map[string]any{}
|
||||
batchBytes := 0
|
||||
// 批次最多 64 元素或约 512 KiB,单个大元素仍受统一 maxLine 限制。
|
||||
flush := func() bool {
|
||||
if len(batch) == 0 {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user