dtot74529 2017-11-30 04:13
浏览 61

redisc.RetryConn返回null

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog