0908
This commit is contained in:
26
aio-mcp/internal/deps/deps.go
Normal file
26
aio-mcp/internal/deps/deps.go
Normal 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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user