mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 16:00:25 +08:00
first
This commit is contained in:
28
scheudler/scheduler.go
Normal file
28
scheudler/scheduler.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package scheduler
|
||||
|
||||
import (
|
||||
"github.com/robfig/cron/v3"
|
||||
"mayfly-go/base"
|
||||
)
|
||||
|
||||
var c = cron.New()
|
||||
|
||||
func Start() {
|
||||
c.Start()
|
||||
}
|
||||
|
||||
func Stop() {
|
||||
c.Stop()
|
||||
}
|
||||
|
||||
func GetCron() *cron.Cron {
|
||||
return c
|
||||
}
|
||||
|
||||
func AddFun(spec string, cmd func()) cron.EntryID {
|
||||
id, err := c.AddFunc(spec, cmd)
|
||||
if err != nil {
|
||||
panic(base.NewBizErr("添加任务失败:" + err.Error()))
|
||||
}
|
||||
return id
|
||||
}
|
||||
Reference in New Issue
Block a user