Browse Source

store the hostinfo on the conn it is dialed

Chris Bannister 10 năm trước cách đây
mục cha
commit
94f8614b24
1 tập tin đã thay đổi với 8 bổ sung0 xóa
  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)
 	}