Files
membank/aio-mcp/internal/deps/deps.go
张威33321 1a6ba86f04 0908
2026-09-08 20:36:25 +08:00

27 lines
800 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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,
}
}