ec9431bfa4
多机/容器化第一时间断裂的隐患(ARCHITECTURE_REVIEW §7 #1):此前报告 源(reportStore)与 .docx 产物(reportExport/reportRender)都写 mcp-go 本地 SUNDYNIX_REPORTS_DIR,gateway 再按同一路径 c.File 回流——mcp-go 与 gateway 不共享磁盘即断。 - blob 包从 gateway/internal 提到 sundynix-shared/blob,gateway 与 mcp-go 共用同一 MinIO;新增 PutBytes/GetBytes 走二进制(.docx)。 - mcp-go 注入 blob:report 源/产物优先 Put 到对象存储(键 reports/<id>.{json,docx}), 导出结果返回 minio://<key>;MinIO 未就绪回退本地盘(单机降级,getSource 兼容旧本地报告)。 - gateway ExportReport 识别 minio:// → GetBytes 流式下载,否则 c.File 本地降级。 - 测试:mcp 本地回落往返单测 + shared/blob 真 MinIO 二进制往返(BLOB_TEST_ENDPOINT 门控)。 四模块 build 绿,受影响测试全过。 - 附带:go mod tidy 引入 genproto 拆包冲突,四模块统一钉单体 genproto 新版解决 (注:勿 go work sync,会剪掉 indirect require 回落旧版重现冲突)。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1.5 KiB
Go
37 lines
1.5 KiB
Go
package contract
|
||
|
||
import (
|
||
"os"
|
||
"path/filepath"
|
||
)
|
||
|
||
// ReportsDir 是报告渲染产物(.docx)的落盘目录。
|
||
// Gateway(下载)与 mcp-go(渲染)跨进程共享同一目录:用环境变量统一,
|
||
// 缺省取系统临时目录下的 sundynix-reports —— 单机开发零配置即可对齐。
|
||
func ReportsDir() string {
|
||
if d := os.Getenv("SUNDYNIX_REPORTS_DIR"); d != "" {
|
||
return d
|
||
}
|
||
return filepath.Join(os.TempDir(), "sundynix-reports")
|
||
}
|
||
|
||
// ReportPath 返回某任务渲染出的 Word 文档绝对路径。
|
||
func ReportPath(id string) string {
|
||
return filepath.Join(ReportsDir(), id+".docx")
|
||
}
|
||
|
||
// ReportSourcePath 返回某报告的源数据(标题 + 章节 JSON)绝对路径。
|
||
// 生成阶段只落源数据;导出时再按需渲染 Word/PDF/Markdown("导出时再处理")。
|
||
func ReportSourcePath(id string) string {
|
||
return filepath.Join(ReportsDir(), id+".json")
|
||
}
|
||
|
||
// 报告源/产物的对象存储键(MinIO)。多进程/多机下用对象存储替代共享本地盘:
|
||
// mcp-go 渲染后 Put,gateway 按键 Get 流式下载,不再依赖跨进程同一磁盘。
|
||
func ReportObjectKey(id string) string { return "reports/" + id + ".docx" }
|
||
func ReportSourceObjectKey(id string) string { return "reports/" + id + ".json" }
|
||
|
||
// BlobScheme 是导出结果里标识“产物在对象存储、按键取”的前缀;
|
||
// 无此前缀则回退按本地路径下载(单机/共享卷时的降级路径)。
|
||
const BlobScheme = "minio://"
|