Documentation
¶
Index ¶
- Constants
- Variables
- func BuildHashTemplate() (*template.Template, error)
- func BuildStringTemplate() (*template.Template, error)
- func ParseDbSpec(dbSpec string) (dbType domain.DbType, dbName string, shardField *domain.Field)
- func ParseFieldFormat(str string) (format string, fields []*domain.Field)
- type ASTParser
- type FileWriter
Constants ¶
View Source
const HashMethods = `` /* 5164-byte string literal not displayed */
View Source
const HashTemplStr = `` /* 1199-byte string literal not displayed */
View Source
const StringMethods = `` /* 2318-byte string literal not displayed */
View Source
const StringTemplStr = `` /* 899-byte string literal not displayed */
Variables ¶
View Source
var TemplateFuncMap = template.FuncMap{
"GetValues": templateGetValues,
"GetArgs": templateGetArgs,
"GetTypeList": templateGetTypeList,
"GetShardArg": templateGetShardArg,
"GetBatchShardArg": templateGetBatchShardArg,
"HasAnyFields": templateHasAnyFields,
"JoinArgs": templateJoinArgs,
"JoinArgsTrail": templateJoinArgsTrail,
"ShardArgDecl": templateShardArgDecl,
"NotUidArgs": templateNotUidArgs,
"CtxCallArgs": templateCtxCallArgs,
"LocalCallArgs": templateLocalCallArgs,
"HasUidField": templateHasUidField,
"fieldCount": templateFieldCount,
}
TemplateFuncMap 模板函数映射,供模板渲染时使用
Functions ¶
func BuildHashTemplate ¶
BuildHashTemplate 构建Hash类型的Go代码模板
func BuildStringTemplate ¶
BuildStringTemplate 构建String类型的Go代码模板
func ParseDbSpec ¶
ParseDbSpec 解析数据库规格字符串,返回 (DbType, 静态DbName/常量引用, ShardField) 支持格式:
- "MyDb" -> (Static, "MyDb", nil) 静态数据库名字面量
- "global:ConstRef" -> (Global, "ConstRef", nil) 全局常量引用(无函数参数) 例如 global:database.REDIS_GLOBAL,其中 database.REDIS_GLOBAL 必须是业务层 database 包自己定义的字符串常量,生成代码时原样透传为 redispool.Get(database.REDIS_GLOBAL)
- "global:Name@string" -> (Global, "", &Field{Name:"Name"}) 全局运行时参数
- "shards:uid@uint64" -> (Shards, "", &Field{...}) 分片路由参数
func ParseFieldFormat ¶
ParseFieldFormat 解析字段格式串 "key:name@type,name2@type2" -> (格式化串, 字段列表) 支持两种格式:
- "prefix:Name@type" → 格式串 "prefix:%d", fields=[{Name,type}] (带前缀)
- "Name@type" → 格式串 "%d", fields=[{Name,type}] (无前缀,纯参数)
这是纯函数,无副作用,可被领域层或基础设施层安全调用
Types ¶
type ASTParser ¶
type ASTParser struct {
// contains filtered or unexported fields
}
ASTParser 基础设施层:AST源码解析器 职责:将Go源码中的 @dbtool 注解解析为领域模型(RedisString/RedisHash)
func (*ASTParser) GetContext ¶
func (p *ASTParser) GetContext() *domain.ParseContext
GetContext 返回填充后的领域上下文(供外部获取解析结果)
type FileWriter ¶
type FileWriter struct {
// contains filtered or unexported fields
}
FileWriter 文件系统输出适配器,实现 domain.OutputPort 接口
Click to show internal directories.
Click to hide internal directories.