feat(capability): 转码能力装配进组合根(工具真进注册表、日志带 source)+ design/25 非bit-exact 留痕更正
This commit is contained in:
1 parent
f91a83ff81
commit
c6f5c3fea0
4 files changed
+87
-3
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/capability/transcode"
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/logger"
|
||||
)
|
||||
|
||||
// transcodeLogSource 是转码能力的日志来源(design/25 §5.3)。引擎自身不带前缀,
|
||||
// 前缀由组合根在这里用 logger.WithSource 接上 —— 漏接则日志无来源,撞
|
||||
// AGENTS §10 红线。
|
||||
const transcodeLogSource = "capability/transcode"
|
||||
|
||||
// wireTranscode 构造本地转码引擎,并把它暴露成能力注册表里的 `transcode` 工具
|
||||
// (design/25 §1.3.2 第二层注册;与 wireVision 同族)。
|
||||
//
|
||||
// 两道失败都**只告警、绝不阻塞启动**:编解码器注册不全(RegistrationError)时引擎
|
||||
// 仍可用已注册的路,工具注册失败(重名等)时能力面缺席、进程内 DI 路径照常。
|
||||
// 转码是可选能力,缺了它其余子系统不受影响,因此这一步没有错误返回值。
|
||||
func (a *app) wireTranscode() {
|
||||
log := logger.WithSource(a.log, transcodeLogSource)
|
||||
tr := transcode.NewEngine(
|
||||
transcode.DefaultLimits(),
|
||||
transcode.WithCodecs(transcode.DefaultCodecs()...),
|
||||
transcode.WithLogger(log),
|
||||
)
|
||||
if err := tr.RegistrationError(); err != nil {
|
||||
log.Warn("transcode codec registration incomplete", "error", err)
|
||||
}
|
||||
a.transcoder = tr
|
||||
if err := transcode.RegisterTool(a.caps, tr); err != nil {
|
||||
log.Warn("transcode tool register skipped", "error", err)
|
||||
return
|
||||
}
|
||||
log.Info("transcode tool registered", "formats", formatNames(tr.Formats()))
|
||||
}
|
||||
|
||||
// formatNames 把已注册的格式转成可读字符串,供启动日志列出这条路支持什么。
|
||||
func formatNames(formats []transcode.Format) []string {
|
||||
names := make([]string, 0, len(formats))
|
||||
for _, f := range formats {
|
||||
names = append(names, transcode.FormatName(f))
|
||||
}
|
||||
return names
|
||||
}
|
||||
Reference in new issue
Block a user