diff --git a/cluster.go b/cluster.go index 1449615..92359cc 100644 --- a/cluster.go +++ b/cluster.go @@ -113,6 +113,12 @@ func InitCluster(ctx context.Context, red redis.UniversalClient, keyPrefix strin // Stop 停止集群定时器 func (l *Cluster) Stop() { close(l.stopChan) + if l.cancel != nil { + l.cancel() + } + if l.usePriority && l.priority != nil { + l.priority.Close() + } l.cleanHeartbeat(true) l.wg.Wait() } diff --git a/once.go b/once.go index 4757635..62ee01b 100644 --- a/once.go +++ b/once.go @@ -166,6 +166,12 @@ func InitOnce(ctx context.Context, re redis.UniversalClient, keyPrefix string, c // Close 停止集群定时器 func (l *Once) Close() { close(l.stopChan) + if l.usePriority && l.priority != nil { + l.priority.Close() + } + if l.leader != nil { + l.leader.Close() + } l.heartbeat.Close() l.cancel() l.wg.Wait()