service.xpcool.com/internal/service/recruitment/scheduler.go

27 lines
908 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package recruitment
import (
"context"
"service.xpcool.com/internal/service/job"
)
// RegisterTasks 把招聘模块的定时任务注册到自动任务调度器(由 job 模块统一纳管)。
// 原 StartScheduler 直接注册 gcron 的方式已废弃:任务定义存 auto_job 表016 SQL 种子),
// 由 job.StartScheduler 按 DB 配置统一调度,支持启停/改 cron/运行日志/完成通知。
func RegisterTasks() {
// 每日 03:00 增量抓取全部启用源
job.Job().Register("recruit-crawl-daily", func(ctx context.Context) (string, error) {
_, summary, e := Recruitment().Trigger(ctx, 0, false)
if e != nil {
return summary, e
}
return summary, nil
})
// 每日 08:00 推送招聘早报(订阅列表)
job.Job().Register("recruit-push-daily", func(ctx context.Context) (string, error) {
sendDailyDigest(ctx)
return "招聘早报推送完成", nil
})
}