47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
|
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)
|
|||
|
}
|