Golang and redis newbie. I have a redis cluster in amazon with 9 nodes. 3 master and for each master we have 2 slaves. Total nine nodes. Not using RetryConn returns a MOVED node error and using it returns a null. Is it important to give the IP address for all the nodes? IS it ok to give the host name that amz gives when we create the cluster.
cluster = redisc.Cluster{
StartupNodes: []string{"*****"},
DialOptions: []redis.DialOption{redis.DialConnectTimeout(5 *
time.Minute)},
CreatePool: createPool,
}
if err := cluster.Refresh(); err != nil {
log.Fatalf("Refresh failed: %v", err)
}else{
log.Println("Refresh worked")
}
func createPool(addr string, opts ...redis.DialOption) (*redis.Pool,
error) {
return &redis.Pool{
MaxIdle: 5,
MaxActive: 10,
IdleTimeout: time.Minute,
Dial: func() (redis.Conn, error) {
c, err := redis.Dial("tcp", "***", opts...)
if err != nil {
log.Panic(err)
}
}, nil
}
func RedisConnection() redis.Conn {
// grab a connection from the pool
conn := cluster.Get()
if(conn != nil){
rc, err := redisc.RetryConn(conn, 9, 1*time.Second)
if(err ==nil){
return rc
}
return nil
}
}
What am I doing wrong? Also how do we binding the conn needed?Any insight would be very helpful