lwl1989 / timing Goto Github PK
View Code? Open in Web Editor NEW一个适用于一次性或者需要重复性任务的执行器,可配合常驻服务实现自动执行定时任务(非类linux CronTab)
License: MIT License
一个适用于一次性或者需要重复性任务的执行器,可配合常驻服务实现自动执行定时任务(非类linux CronTab)
License: MIT License
复现代码:
task := &timing2.Task{
Uuid: "uuid",
Job: timing2.GetJob(func() {
panic("err")
}),
RunTime: time.Now().Unix() + 90,
}
异常代码处:
job.go func (j *taskJob) run()
原因是 defer的顺序是 先进后出,原代码会先触发 j.done <- true 然后进行了 finish的逻辑,代码应改为:
defer func() {
if !isPanic {
j.done <- true
}
}()
defer func() {
if x := recover(); x != nil {
err := errors.Errorf("job error with panic:%v", x)
j.err <- err
isPanic = true
return
}
}()
你好, 在TaskScheduler.run 方法中,for循环存在的意义是什么?最后加了break,可见for循环只执行了一次
还是有些问题哦老哥
timer.go文件里面的addTask方法没有处理runtime
timer.go文件有几处理应替换addTask方法变为AddTask方法
func (scheduler *TaskScheduler) AddFuncSpaceNumber(spaceTime int64, number int, f func()) {
task := getTaskWithFuncSpacingNumber(spaceTime, number, f)
scheduler.AddTask(task)
}
//add spacing time job to list with endTime
func (scheduler *TaskScheduler) AddFuncSpace(spaceTime int64, endTime int64, f func()) {
task := getTaskWithFuncSpacing(spaceTime, endTime, f)
scheduler.AddTask(task)
}
//add func to list
func (scheduler *TaskScheduler) AddFunc(unixTime int64, f func()) {
task := getTaskWithFunc(unixTime, f)
scheduler.AddTask(task)
}
老哥bug一大堆 编译都过不了 你确定能用?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.