添加停止需要释放的资源
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user