执行一次的调试

This commit is contained in:
Yun
2024-10-09 17:03:54 +08:00
parent cf3e751afe
commit fa8e3737fa
2 changed files with 48 additions and 2 deletions
+24 -1
View File
@@ -24,12 +24,35 @@ func main() {
// re()
// d()
cluster()
// cluster()
once()
select {}
}
func once() {
client := getRedis()
ctx := context.Background()
w := OnceWorker{}
one := timerx.InitOnce(ctx, client, "test", w)
err := one.Save("test", "test", 1*time.Second, map[string]interface{}{})
if err != nil {
fmt.Println(err)
}
}
type OnceWorker struct{}
func (l OnceWorker) Worker(ctx context.Context, taskType string, taskId string, attachData interface{}) (timerx.WorkerCode, time.Duration) {
fmt.Println("执行时间:", time.Now().Format("2006-01-02 15:04:05"))
fmt.Println(taskId, taskType)
fmt.Println(attachData)
return timerx.WorkerCodeAgain, time.Millisecond
}
func cluster() {
client := getRedis()
ctx := context.Background()