We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent be4c4f3 commit a46b053Copy full SHA for a46b053
ring.go
@@ -273,16 +273,20 @@ func (c *ringShards) Heartbeat(frequency time.Duration) {
273
274
// rebalance removes dead shards from the Ring.
275
func (c *ringShards) rebalance() {
276
+ c.mu.RLock()
277
+ shards := c.shards
278
+ c.mu.RUnlock()
279
+
280
hash := newConsistentHash(c.opt)
281
var shardsNum int
- c.mu.Lock()
- for name, shard := range c.shards {
282
+ for name, shard := range shards {
283
if shard.IsUp() {
284
hash.Add(name)
285
shardsNum++
286
}
287
288
289
+ c.mu.Lock()
290
c.hash = hash
291
c.len = shardsNum
292
c.mu.Unlock()
0 commit comments