Closed andyli029 closed 8 years ago
Can you explain why more than one address would be better?
@mediocregopher when the address is failed,you can visit the next addr to avoid single point of failure. in other RedisCluster SDKS,in general multiple addresses are used, so the RedisCluster class will iterate over the provided nodes until it can attain a connection to the cluster
It's not a bad idea, unfortunately there's not a very clean way to introduce it to the api right now, but I'll keep it in mind for the next iteration. In the meantime you could write a simple loop that does effectively the same thing:
var c *cluster.Cluster
var lastErr error
opts := cluster.Opts{ ... }
for _, addr := range addrs {
opts.Addr = addr
if c, lastErr = cluster.NewWithOpts(opts); lastErr == nil {
break
}
}
if lastErr != nil {
panic(lastErr)
}
@mediocregopher Thanks a lot.
type Opts struct {
..... }