MCPcopy
hub / github.com/redis/go-redis / rebalanceLocked

Method rebalanceLocked

ring.go:524–542  ·  view source on GitHub ↗

rebalanceLocked removes dead shards from the Ring. Requires c.mu locked.

()

Source from the content-addressed store, hash-verified

522// rebalanceLocked removes dead shards from the Ring.
523// Requires c.mu locked.
524func (c *ringSharding) rebalanceLocked() {
525 if c.closed {
526 return
527 }
528 if c.shards == nil {
529 return
530 }
531
532 liveShards := make([]string, 0, len(c.shards.m))
533
534 for name, shard := range c.shards.m {
535 if shard.IsUp() {
536 liveShards = append(liveShards, name)
537 }
538 }
539
540 c.hash = c.opt.NewConsistentHash(liveShards)
541 c.numShard = len(liveShards)
542}
543
544func (c *ringSharding) Len() int {
545 c.mu.RLock()

Callers 3

SetAddrsMethod · 0.95
HeartbeatMethod · 0.95

Calls 1

IsUpMethod · 0.80

Tested by 1