net_transport.go
func (n *NetworkTransport) getConn(target ServerAddress) (*netConn, error) {
	// Check for a pooled conn
	if conn := n.getPooledConn(target); conn != nil {
		return conn, nil
	}

	// Dial a new connection
	conn, err := n.stream.Dial(target, n.timeout)
	if err != nil {
		return nil, err
	}

	// Wrap the conn
	netConn := &netConn{
		target: target,
		conn:   conn,
		r:      bufio.NewReader(conn),
		w:      bufio.NewWriter(conn),
	}

	// Setup encoder/decoders
	netConn.dec = codec.NewDecoder(netConn.r, &codec.MsgpackHandle{})
	netConn.enc = codec.NewEncoder(netConn.w, &codec.MsgpackHandle{})

	// Done
	return netConn, nil
}
func (n *NetworkTransport) getConn(target ServerAddress) (*netConn, error) {
	// Check for a pooled conn
	if conn := n.getPooledConn(target); conn != nil {
		return conn, nil
	}

	// Dial a new connection
	conn, err := n.stream.Dial(target, n.timeout)
	if err != nil {
		return nil, err
	}

	// Wrap the conn
	netConn := &netConn{
		target: target,
		conn:   conn,
		r:      bufio.NewReader(conn),
		w:      bufio.NewWriter(conn),
	}

	// Setup encoder/decoders
	netConn.dec = codec.NewDecoder(netConn.r, &codec.MsgpackHandle{})
	netConn.enc = codec.NewEncoder(netConn.w, &codec.MsgpackHandle{})

	// Done
	return netConn, nil
}
func ( n * NetworkTransport ) getConn ( target ServerAddress ) ( * netConn , error ) { // Check for a pooled conn if conn := n . getPooledConn ( target ) ; conn != nil { return conn , nil } // Dial a new connection conn , err := n . stream . Dial ( target , n . timeout ) if err != nil { return nil , err } // Wrap the conn netConn := & netConn { target : target , conn : conn , r : bufio . NewReader ( conn ) , w : bufio . NewWriter ( conn ) , } // Setup encoder/decoders netConn . dec = codec . NewDecoder ( netConn . r , & codec . MsgpackHandle { } ) netConn . enc = codec . NewEncoder ( netConn . w , & codec . MsgpackHandle { } ) // Done return netConn , nil }
// getConn is used to get a connection from the pool.
getConn is used to get a connection from the pool .