@@ -422,6 +422,7 @@ func (c *ringSharding) Heartbeat(ctx context.Context, frequency time.Duration) {
422
422
case <- ticker .C :
423
423
var rebalance bool
424
424
425
+ // note: `c.List()` return a shadow copy of `[]*ringShard`.
425
426
for _ , shard := range c .List () {
426
427
err := shard .Client .Ping (ctx ).Err ()
427
428
isUp := err == nil || err == pool .ErrPoolTimeout
@@ -581,6 +582,7 @@ func (c *Ring) retryBackoff(attempt int) time.Duration {
581
582
582
583
// PoolStats returns accumulated connection pool stats.
583
584
func (c * Ring ) PoolStats () * PoolStats {
585
+ // note: `c.List()` return a shadow copy of `[]*ringShard`.
584
586
shards := c .sharding .List ()
585
587
var acc PoolStats
586
588
for _ , shard := range shards {
@@ -650,6 +652,7 @@ func (c *Ring) ForEachShard(
650
652
ctx context.Context ,
651
653
fn func (ctx context.Context , client * Client ) error ,
652
654
) error {
655
+ // note: `c.List()` return a shadow copy of `[]*ringShard`.
653
656
shards := c .sharding .List ()
654
657
var wg sync.WaitGroup
655
658
errCh := make (chan error , 1 )
@@ -681,6 +684,7 @@ func (c *Ring) ForEachShard(
681
684
}
682
685
683
686
func (c * Ring ) cmdsInfo (ctx context.Context ) (map [string ]* CommandInfo , error ) {
687
+ // note: `c.List()` return a shadow copy of `[]*ringShard`.
684
688
shards := c .sharding .List ()
685
689
var firstErr error
686
690
for _ , shard := range shards {
0 commit comments