This commit is contained in:
张威33321
2026-09-08 20:36:25 +08:00
parent 6296202eb0
commit 1a6ba86f04
13 changed files with 314 additions and 104 deletions

View File

@@ -0,0 +1,26 @@
// Package deps 定义工具共享的依赖容器。
//
// 工具分组internal/tools/xxx在注册时接收同一个 *Deps
// 避免各工具各自打开数据库连接、各自读配置。
package deps
import (
"aio-mcp/internal/config"
)
// Deps 是注册工具时注入的共享依赖。
//
// 目前只有数据目录;后续按需在这里加字段即可:
// SQLite 连接(*sql.DB、HTTP client、打印机客户端、检测服务客户端等。
// 由 internal/deps.New 统一构造,各工具只从参数取值,不再自建。
type Deps struct {
// DataDir 是数据目录SQLite 库文件与工具产物的根路径。
DataDir string
}
// New 依据启动配置构造共享依赖。
func New(cfg *config.Config) *Deps {
return &Deps{
DataDir: cfg.DataDir,
}
}