xxl-job-executor-go
xxl-job-executor-go copied to clipboard
yoyogo框架已集成xxl-job-executor-go项目,讨论日志功能能否集成到xxl-job-executor-go项目中?
案例:
https://github.com/yoyofx/yoyogo/tree/dev/examples/xxl-job-console 已支持xxl-job日志(实时获取)
func main() {
// -f ./conf/test_conf.yml 指定配置文件 , 默认读取 config_{profile}.yml , -profile [dev,test,prod]
config := configuration.YAML("config")
scheduler.NewXxlJobBuilder(config).
ConfigureServices(func(collection *dependencyinjection.ServiceCollection) {
scheduler.AddJobs(collection, NewDemoJob)
}).
Build().Run()
}
type DemoJob struct {}
func NewDemoJob() *DemoJob {
return &DemoJob{}
}
func (*DemoJob) Execute(cxt *scheduler.JobContext) (msg string) {
cxt.Report("Job %d is beginning...", cxt.LogID)
for i := 1; i <= 100; i++ {
cxt.Report("Job Progress: %d Percent.", i)
time.Sleep(time.Second)
}
return cxt.Done("666")
}
//GetJobName 自定义任务的名字
func (*DemoJob) GetJobName() string {
return "job1"
}
只要实现日志接口就可以集成到该项目,参考:https://github.com/xxl-job/xxl-job-executor-go/blob/master/log.go
我是指 LogHandler
我是指 LogHandler
LogHandler 是个接口函数,,直接实现你的逻辑,把你实现的函数设置进去即可: 实现接口: func(req *LogReq) *LogRes 设置: exec.LogHandler(你自己实现的LogHandler)
明白,我的意思是否sdk提供默认的实现,跟java实现一样,如果需要我想可以贡献一个
欢迎为该项目贡献代码