gf icon indicating copy to clipboard operation
gf copied to clipboard

gron的表达式解析和定时器功能分离

Open 15951836388 opened this issue 6 years ago • 4 comments

type Schedule interface {
	// Next returns the next activation time, later than the given time.
	// Next is invoked initially, and then each time the job is run.
	Next(time.Time) time.Time
}
type SpecSchedule struct {
	Second, Minute, Hour, Dom, Month, Dow uint64

	// Override location for this schedule.
	Location *time.Location
}

表达式解析出来的是SpecSchedule (实现了Schedule ) 对于定时器来说,只要实现 Next(time.Time) time.Time 方法就行,没有耦合

详细可参考 github.com/robfig/cron/v3

15951836388 avatar Dec 03 '19 07:12 15951836388

@15951836388 能描述一下你的业务场景吗?

gqcn avatar Dec 10 '19 11:12 gqcn

我只是想用cron的表达式解析而已,并不需要用定时任务系统。 而且出于解耦的方面考虑,也不该把2个功能关联死吧

15951836388 avatar Dec 11 '19 05:12 15951836388

大佬,有分离的计划吗?我只要用表达式解析这个功能

15951836388 avatar Dec 18 '20 08:12 15951836388

@15951836388 你提的建议不错,不过不是最优先的工作计划,感兴趣的话可以提PR,或者等待其他小伙伴贡献吧。

gqcn avatar Dec 18 '20 15:12 gqcn