cutego/core/job/index.go

22 lines
460 B
Go
Raw Normal View History

2022-03-01 13:50:13 +08:00
package job
import (
"cutego/core/service"
"cutego/pkg/common"
)
// 定时任务: 别名与方法的映射
var AliasFuncMap = make(map[string]func())
// 注册任务
func RegisterFunc(aliasName string, f func()) {
currentJob := service.CronJobService{}.GetInfoByAlias(aliasName)
AliasFuncMap[aliasName] = f
common.InfoLogf("注册定时任务 --- %s ---> Success", currentJob.JobName)
}
// 注册方法
func init() {
2022-03-01 17:43:41 +08:00
RegisterFunc("test1", TestJob)
2022-03-01 13:50:13 +08:00
}