1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

cluster: don't reset command when there no attempts left.

This commit is contained in:
Vladimir Mihailenco
2015-05-10 16:01:38 +03:00
parent 2507be6cd2
commit 7f1eb05ba8
2 changed files with 27 additions and 8 deletions

View File

@ -130,6 +130,10 @@ func (c *ClusterClient) process(cmd Cmder) {
}
for attempt := 0; attempt <= c.opt.getMaxRedirects(); attempt++ {
if attempt > 0 {
cmd.reset()
}
if ask {
pipe := client.Pipeline()
pipe.Process(NewCmd("ASKING"))
@ -152,7 +156,6 @@ func (c *ClusterClient) process(cmd Cmder) {
if err != nil {
return
}
cmd.reset()
continue
}
@ -167,7 +170,6 @@ func (c *ClusterClient) process(cmd Cmder) {
if err != nil {
return
}
cmd.reset()
continue
}
@ -282,6 +284,9 @@ type ClusterOptions struct {
}
func (opt *ClusterOptions) getMaxRedirects() int {
if opt.MaxRedirects == -1 {
return 0
}
if opt.MaxRedirects == 0 {
return 16
}