forked from mirror/redis
Merge pull request #104 from go-redis/fix/use-cluster-info-to-ping
cluster: user ClusterInfo instead of Ping to find live node.
This commit is contained in:
commit
6ee0a9b9f5
|
@ -97,7 +97,7 @@ func (c *ClusterClient) slotAddrs(slot int) []string {
|
||||||
return addrs
|
return addrs
|
||||||
}
|
}
|
||||||
|
|
||||||
// randomClient returns a Client for the first pingable node.
|
// randomClient returns a Client for the first live node.
|
||||||
func (c *ClusterClient) randomClient() (client *Client, err error) {
|
func (c *ClusterClient) randomClient() (client *Client, err error) {
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
n := rand.Intn(len(c.addrs))
|
n := rand.Intn(len(c.addrs))
|
||||||
|
@ -105,7 +105,7 @@ func (c *ClusterClient) randomClient() (client *Client, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
err = client.Ping().Err()
|
err = client.ClusterInfo().Err()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,7 @@ var _ = Describe("Cluster", func() {
|
||||||
|
|
||||||
Eventually(func() []string {
|
Eventually(func() []string {
|
||||||
return client.SlotAddrs(slot)
|
return client.SlotAddrs(slot)
|
||||||
}).Should(Equal([]string{"127.0.0.1:8221", "127.0.0.1:8224"}))
|
}, "5s").Should(Equal([]string{"127.0.0.1:8221", "127.0.0.1:8224"}))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should perform multi-pipelines", func() {
|
It("should perform multi-pipelines", func() {
|
||||||
|
|
Loading…
Reference in New Issue