优化定时器的表述
This commit is contained in:
+2
-2
@@ -30,7 +30,7 @@ func main() {
|
|||||||
|
|
||||||
func worker() {
|
func worker() {
|
||||||
client := getRedis()
|
client := getRedis()
|
||||||
w := timerx.InitOnce(context.Background(), client, &Worker{})
|
w := timerx.InitOnce(context.Background(), client,"test", &Worker{})
|
||||||
w.Add("test", "test", 1*time.Second, map[string]interface{}{
|
w.Add("test", "test", 1*time.Second, map[string]interface{}{
|
||||||
"test": "test",
|
"test": "test",
|
||||||
})
|
})
|
||||||
@@ -52,7 +52,7 @@ func worker() {
|
|||||||
|
|
||||||
type Worker struct{}
|
type Worker struct{}
|
||||||
|
|
||||||
func (w *Worker) Worker(uniqueKey string, jobType string, data interface{}) (timerx.WorkerCode, time.Duration) {
|
func (w *Worker) Worker(jobType string,uniqueKey string, data interface{}) (timerx.WorkerCode, time.Duration) {
|
||||||
fmt.Println("执行时间:", time.Now().Format("2006-01-02 15:04:05"))
|
fmt.Println("执行时间:", time.Now().Format("2006-01-02 15:04:05"))
|
||||||
fmt.Println(uniqueKey, jobType)
|
fmt.Println(uniqueKey, jobType)
|
||||||
fmt.Println(data)
|
fmt.Println(data)
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 功能描述
|
// 功能描述
|
||||||
// 1. 任务全局唯一
|
// 1. 任务可以多节点发布
|
||||||
// 2. 任务只执行一次
|
// 2. 每个任务的执行在全局仅会执行一次
|
||||||
// 3. 任务执行失败可以重新放入队列
|
// 3. 任务执行失败支持快捷重新加入队列
|
||||||
|
|
||||||
// 单次的任务队列
|
// 单次的任务队列
|
||||||
type worker struct {
|
type worker struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user