瀏覽代碼

store the hostinfo on the conn it is dialed

Chris Bannister 10 年之前
父節點
當前提交
94f8614b24
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      conn.go

+ 8 - 0
conn.go

@@ -131,6 +131,7 @@ type Conn struct {
 	version         uint8
 	currentKeyspace string
 	started         bool
+	host            *HostInfo
 
 	session *Session
 
@@ -191,6 +192,13 @@ func Connect(addr string, cfg *ConnConfig, errorHandler ConnErrorHandler, sessio
 		streams:      streams.New(cfg.ProtoVersion),
 	}
 
+	host, _, err := net.SplitHostPort(addr)
+	if err != nil {
+		conn.Close()
+		return nil, err
+	}
+	c.host = session.ring.getHost(host)
+
 	if cfg.Keepalive > 0 {
 		c.setKeepalive(cfg.Keepalive)
 	}