重构: base 包资源核心类型迁移到 req/resx,新增 res_watcher/res_api_param
base/resource.go、resource_hooks.go、resource_test.go、query_field.go 删除,ResField 等具体实现搬到 req/resx(见 res_field.go 里的类型别名)。res_listener.go 替换成 res_watcher.go,对应资源变更监听概念改名。新增 res_api_param.go 及配套测试(ResApi 参数建模,给 MCP tool 的 JSON Schema 生成用)。
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package base
|
||||
|
||||
// ResWatcher 描述一条"资源写操作监听"注册记录:Code 对应一个实现了 contracts.ResWatcher 的处理器,
|
||||
// ResourceUuids 是它关心的资源(支持 1-n 个)
|
||||
type ResWatcher struct {
|
||||
Uuid string `db:"uuid"`
|
||||
Code string `db:"code"`
|
||||
Name string `db:"name"`
|
||||
ResourceUuids []string `db:"resource_uuid"`
|
||||
OwnedUser string `db:"owned_user"` // Handle 执行时使用的用户身份(同 Cron/Mqtt 约定)
|
||||
MaxDepth int `db:"max_depth"` // 允许级联触发的最大深度,用于防止 watcher 之间循环触发
|
||||
UpdatedAt string `db:"updated_at"`
|
||||
CreatedAt string `db:"created_at"`
|
||||
}
|
||||
|
||||
// GetResWatcher 按 code 查询单条 ResWatcher 注册记录
|
||||
type GetResWatcher func(code string) (ResWatcher, bool)
|
||||
|
||||
// GetResWatchers 按资源 uuid 反查关心该资源的 ResWatcher 注册记录
|
||||
type GetResWatchers func(resourceUuid string) []ResWatcher
|
||||
Reference in New Issue
Block a user