集群定时器添加优先级

This commit is contained in:
Yun
2025-06-11 15:12:08 +08:00
parent 3716f97eaf
commit ecaac58926
3 changed files with 160 additions and 20 deletions
+3 -3
View File
@@ -24,8 +24,8 @@ func main() {
// re()
// d()
// cluster()
once()
cluster()
// once()
select {}
@@ -89,7 +89,7 @@ func (l OnceWorker) Worker(ctx context.Context, taskType string, taskId string,
func cluster() {
client := getRedis()
ctx := context.Background()
cluster := timerx.InitCluster(ctx, client, "test")
cluster := timerx.InitCluster(ctx, client, "test",timerx.SetPriority(101))
err := cluster.EverySpace(ctx, "test_space", 1*time.Second, aa, "这是秒任务")
fmt.Println(err)
err = cluster.EveryMinute(ctx, "test_min", 15, aa, "这是分钟任务")