Skip to content

可以考虑包内实现定时任务库 #48

@libi

Description

@libi

可以考虑将 robfig/cron 完全内置:
对内可以实现更精准的任务执行时机判断。
对外用户调用接口将与robfig/cron完全一致,只通过替换包名即可无缝替换单机模式。 如果需要分布式支持,只需要配置额外的 option 选项开启分布式。

例如开启某个定时任务:
cron 用法

 c := cron.New(cron.WithSeconds()) 
 c.AddJob("* * * * * ?", job)
 c.Start()

dcron用法

 c := dcron.New(dcron.WithSeconds()) 
 c.AddJob("* * * * * ?", job)
 c.Start()

如需开启分布式时:

 c := dcron.New(dcron.WithSeconds(),dcron.WithDistributed(dcron.Driver)) 
 c.AddJob("* * * * * ?", job)
 c.Start()

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions