2022-11-24 23:37:34 +08:00
|
|
|
// Package crons
|
|
|
|
// @Link https://github.com/bufanyun/hotgo
|
2023-02-23 17:53:04 +08:00
|
|
|
// @Copyright Copyright (c) 2023 HotGo CLI
|
2022-11-24 23:37:34 +08:00
|
|
|
// @Author Ms <133814250@qq.com>
|
|
|
|
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
|
|
|
package crons
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2023-06-05 20:14:57 +08:00
|
|
|
"hotgo/internal/library/cron"
|
2022-11-24 23:37:34 +08:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2023-01-25 11:49:21 +08:00
|
|
|
func init() {
|
2023-06-05 20:14:57 +08:00
|
|
|
cron.Register(Test)
|
2023-01-25 11:49:21 +08:00
|
|
|
}
|
|
|
|
|
2023-02-23 17:53:04 +08:00
|
|
|
// Test 测试任务(无参数)
|
2022-11-24 23:37:34 +08:00
|
|
|
var Test = &cTest{name: "test"}
|
|
|
|
|
|
|
|
type cTest struct {
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *cTest) GetName() string {
|
|
|
|
return c.name
|
|
|
|
}
|
|
|
|
|
|
|
|
// Execute 执行任务
|
2023-11-25 18:36:11 +08:00
|
|
|
func (c *cTest) Execute(ctx context.Context, parser *cron.Parser) (err error) {
|
|
|
|
parser.Logger.Infof(ctx, "cron test Execute:%v", time.Now())
|
|
|
|
return
|
2022-11-24 23:37:34 +08:00
|
|
|
}
|