uniugm/admin/lib/node/node_options.go

47 lines
1.4 KiB
Go
Raw Normal View History

2025-04-18 17:17:23 +08:00
package node
// WithNodeBootFlags 设置启动参数解析结构
//func WithNodeBootFlags(f *CommonBootFlags) NodeOption {
// return nodeOptionFun(func(node *Node) {
// node.globalBootFlag = f
// })
//}
// WithNodeBootConfigFileContent 设置启动配置文件的解析结构不设置默认无起服配置默认以yaml解析
func WithNodeBootConfigFileContent(content IBootConfigContent) NodeOption {
return nodeOptionFun(func(node *Node) {
node.bootConfigFile.globalBootConfigFileContent = content
})
}
// WithNodeExBootFlags 设置额外的启动参数解析结构
func WithNodeExBootFlags(content any) NodeOption {
return nodeOptionFun(func(node *Node) {
node.bootFlags.exBootFlag = content
})
}
// WithNodeBootConfigFileParser 设置起服文件解析函数默认yaml格式
func WithNodeBootConfigFileParser(f func(content []byte, out interface{}) error) NodeOption {
return nodeOptionFun(func(node *Node) {
node.bootConfigFile.globalBootConfigParser = f
})
}
// WithNodeLogFileTimestampFormat 设置日志文件默认时间戳格式,默认"20060102"
//func WithNodeLogFileTimestampFormat(format string) NodeOption {
// return appOptionFun(func(node *Node) {
// node.xlog.logFileTsFormat = format
// })
//}
type NodeOption interface {
Apply(app *Node)
}
type nodeOptionFun func(node *Node)
func (of nodeOptionFun) Apply(node *Node) {
of(node)
}