Browse Source

add session.connect to dial connections

Chris Bannister 10 years ago
parent
commit
b13e734abb
3 changed files with 8 additions and 3 deletions
  1. 1 1
      connectionpool.go
  2. 3 2
      control.go
  3. 4 0
      session.go

+ 1 - 1
connectionpool.go

@@ -455,7 +455,7 @@ func (pool *hostConnPool) fillingStopped() {
 // create a new connection to the host and add it to the pool
 // create a new connection to the host and add it to the pool
 func (pool *hostConnPool) connect() error {
 func (pool *hostConnPool) connect() error {
 	// try to connect
 	// try to connect
-	conn, err := Connect(pool.addr, pool.connCfg, pool, pool.session)
+	conn, err := pool.session.connect(pool.addr, pool)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}

+ 3 - 2
control.go

@@ -91,12 +91,13 @@ func (c *controlConn) connect(endpoints []string) error {
 
 
 	var (
 	var (
 		conn *Conn
 		conn *Conn
+		err  error
 	)
 	)
 
 
 	for _, addr := range shuffled {
 	for _, addr := range shuffled {
-		conn, err = Connect(JoinHostPort(addr, c.session.cfg.Port), connCfg, c, c.session)
+		conn, err = c.session.connect(JoinHostPort(addr, c.session.cfg.Port), c)
 		if err != nil {
 		if err != nil {
-			log.Printf("gocql: unable to dial %v: %v\n", addr, err)
+			log.Printf("gocql: unable to control conn dial %v: %v\n", addr, err)
 			continue
 			continue
 		}
 		}
 
 

+ 4 - 0
session.go

@@ -525,6 +525,10 @@ func (s *Session) MapExecuteBatchCAS(batch *Batch, dest map[string]interface{})
 	}
 	}
 }
 }
 
 
+func (s *Session) connect(addr string, errorHandler ConnErrorHandler) (*Conn, error) {
+	return Connect(addr, s.connCfg, errorHandler, s)
+}
+
 // Query represents a CQL statement that can be executed.
 // Query represents a CQL statement that can be executed.
 type Query struct {
 type Query struct {
 	stmt             string
 	stmt             string