1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-31 05:04:23 +03:00

Remove Redis Cluster state check

This commit is contained in:
Vladimir Mihailenco
2018-11-24 13:16:21 +02:00
parent 78a66f0e5f
commit 17e8439f2f
3 changed files with 30 additions and 42 deletions

View File

@ -582,13 +582,6 @@ func (c *clusterState) slotNodes(slot int) []*clusterNode {
return nil
}
func (c *clusterState) IsConsistent() bool {
if c.nodes.opt.ClusterSlots != nil {
return true
}
return len(c.Masters) <= len(c.Slaves)
}
//------------------------------------------------------------------------------
type clusterStateHolder struct {
@ -613,9 +606,6 @@ func (c *clusterStateHolder) Reload() (*clusterState, error) {
if err != nil {
return nil, err
}
if !state.IsConsistent() {
time.AfterFunc(time.Second, c.LazyReload)
}
return state, nil
}
@ -640,16 +630,11 @@ func (c *clusterStateHolder) LazyReload() {
go func() {
defer atomic.StoreUint32(&c.reloading, 0)
for {
state, err := c.reload()
if err != nil {
return
}
time.Sleep(100 * time.Millisecond)
if state.IsConsistent() {
return
}
_, err := c.reload()
if err != nil {
return
}
time.Sleep(100 * time.Millisecond)
}()
}