From 49f9e8bde63983b7da41bef4c4d15cd2fb3705e8 Mon Sep 17 00:00:00 2001 From: Yun Date: Tue, 14 Oct 2025 12:07:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=BB=E5=8A=A1=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=89=A7=E8=A1=8C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cluster.go | 2 +- once.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cluster.go b/cluster.go index 8d4fc1d..3a69a89 100644 --- a/cluster.go +++ b/cluster.go @@ -529,7 +529,7 @@ func (c *Cluster) executeTasks() { return case <-c.ctx.Done(): return - case <-c.workerChan: + case c.workerChan <- struct{}{}: if c.usePriority && !c.priority.IsLatest(c.ctx) { time.Sleep(5 * time.Second) continue diff --git a/once.go b/once.go index eab1134..493e638 100644 --- a/once.go +++ b/once.go @@ -121,8 +121,8 @@ func InitOnce(ctx context.Context, re redis.UniversalClient, keyPrefix string, c keySeparator: "[:]", timeout: op.timeout, maxRunCount: op.maxRunCount, - workerChan: make(chan struct{}, op.maxRunCount), - maxWorkers: op.maxRunCount, + workerChan: make(chan struct{}, op.maxWorkers), + maxWorkers: op.maxWorkers, } // 初始化优先级 @@ -289,7 +289,8 @@ func (l *Once) executeTasks() { return case <-l.ctx.Done(): return - case <-l.workerChan: + case l.workerChan <- struct{}{}: + keys, err := l.redis.BLPop(l.ctx, time.Second*10, l.listKey).Result() if err != nil { if err != redis.Nil {