package
Version:
v0.1.1
Opens a new window with list of versions in this module.
Published: Jan 15, 2025
License: MIT
Opens a new window with license information.
Imports: 3
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
定时任务使用方法
1. 实现Jober
接口,注册任务
例如:
// 注册任务
func init() {
timer.RegisterJob(&TestTimer{})
}
// 实现Jober接口
type TestTimer struct {
}
func (t *TestTimer) GetName() string {
return "TestTimer"
}
func (t *TestTimer) GetCron() string {
return "*/1 * * * *"
}
func (t *TestTimer) Run() {
log.Println("TestTimer is run")
}
2. 在入口出引入即可
例: import _ "gintpl/internal/timer"
Documentation
¶
func RegisterJob(job Jober)
RegisterJob 注册任务
type Jober interface {
cron.Job
GetName() string
GetCron() string
}
Jober 任务接口
Source Files
¶
Click to show internal directories.
Click to hide internal directories.