xxl-job-executor-go icon indicating copy to clipboard operation
xxl-job-executor-go copied to clipboard

yoyogo框架已集成xxl-job-executor-go项目,讨论日志功能能否集成到xxl-job-executor-go项目中?

Open yoyofx opened this issue 3 years ago • 5 comments

案例:

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"
}

yoyofx avatar May 25 '21 11:05 yoyofx

只要实现日志接口就可以集成到该项目,参考:https://github.com/xxl-job/xxl-job-executor-go/blob/master/log.go

rushuinet avatar May 26 '21 03:05 rushuinet

我是指 LogHandler

yoyofx avatar May 26 '21 03:05 yoyofx

我是指 LogHandler

LogHandler 是个接口函数,,直接实现你的逻辑,把你实现的函数设置进去即可: 实现接口: func(req *LogReq) *LogRes 设置: exec.LogHandler(你自己实现的LogHandler)

rushuinet avatar Jun 02 '21 05:06 rushuinet

明白,我的意思是否sdk提供默认的实现,跟java实现一样,如果需要我想可以贡献一个

yoyofx avatar Jun 04 '21 12:06 yoyofx

欢迎为该项目贡献代码

rushuinet avatar Jun 07 '21 01:06 rushuinet