// NewConnection returns an initialized Connection instance
18346
func NewConnection(c net.Conn, p *ConnectionPool) *Connection {
	return &Connection{
		Conn:          c,
		owner:         p,
		returnOnClose: true,
	}
}
818874
func NewDBConnection(info *mysql.ConnParams, mysqlStats *stats.Timings) (*DBConnection, error) {
	start := time.Now()
	defer mysqlStats.Record("Connect", start)
	params, err := dbconfigs.WithCredentials(info)
	if err != nil {
		return nil, err
	}
	ctx := context.Background()
	c, err := mysql.Connect(ctx, params)
	if err != nil {
		mysqlStats.Record("ConnectError", start)
	}
	return &DBConnection{c, mysqlStats}, err
}
666745
func NewConnection(skipSSLValidation bool, disableKeepAlives bool, dialTimeout time.Duration) *UAAConnection {
	tr := &http.Transport{
		DialContext: (&net.Dialer{
			KeepAlive: 30 * time.Second,
			Timeout:   dialTimeout,
		}).DialContext,
		DisableKeepAlives: disableKeepAlives,
		Proxy:             http.ProxyFromEnvironment,
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: skipSSLValidation,
		},
	}

	return &UAAConnection{
		HTTPClient: &http.Client{
			Transport: tr,
			CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
				// This prevents redirects. When making a request to /oauth/authorize,
				// the client should not follow redirects in order to obtain the ssh
				// passcode.
				return http.ErrUseLastResponse
			},
		},
	}
}
518618
func (n *NotifyRouter) AddConnection(xp rpc.Transporter, ch chan error) ConnectionID {
	if n == nil {
		return 0
	}
	id := n.cm.AddConnection(xp, ch)
	n.setNotificationChannels(id, keybase1.NotificationChannels{})
	return id
}
1039193
func NewConnect(uri string) (*Connect, error) {
	var cUri *C.char
	if uri != "" {
		cUri = C.CString(uri)
		defer C.free(unsafe.Pointer(cUri))
	}
	var err C.virError
	ptr := C.virConnectOpenWrapper(cUri, &err)
	if ptr == nil {
		return nil, makeError(&err)
	}
	return &Connect{ptr: ptr}, nil
}
148910
func NewConn() *Conn {
	return &Conn{
		ReceiveNow: make(chan bool),
		stats:      make(map[cmdHash]int),
	}
}
670724
func (mux *Multiplexer) NewBytesConnection(name string) *BytesConnectionStr {
	return &BytesConnectionStr{BytesConnectionFields{multiplexer: mux, name: name}}
}
763768
func NewConnection(config ConnectionConfig) (driver.Connection, error) {
	c, err := cluster.NewConnection(config.ConnectionConfig, func(endpoint string) (driver.Connection, error) {
		conn, err := newVSTConnection(endpoint, config)
		if err != nil {
			return nil, driver.WithStack(err)
		}
		return conn, nil
	}, config.Endpoints)
	if err != nil {
		return nil, driver.WithStack(err)
	}
	return c, nil
}
365101
func NewConnection(policy *ClientPolicy, host *Host) (*Connection, error) {
	address := net.JoinHostPort(host.Name, strconv.Itoa(host.Port))
	conn, err := newConnection(address, policy.Timeout)
	if err != nil {
		return nil, err
	}

	if policy.TlsConfig == nil {
		return conn, nil
	}

	// Use version dependent clone function to clone the config
	tlsConfig := cloneTLSConfig(policy.TlsConfig)
	tlsConfig.ServerName = host.TLSName

	sconn := tls.Client(conn.conn, tlsConfig)
	if err := sconn.Handshake(); err != nil {
		sconn.Close()
		return nil, err
	}

	if host.TLSName != "" && !tlsConfig.InsecureSkipVerify {
		if err := sconn.VerifyHostname(host.TLSName); err != nil {
			sconn.Close()
			Logger.Error("Connection to address `" + address + "` failed to establish with error: " + err.Error())
			return nil, errToTimeoutErr(nil, err)
		}
	}

	conn.conn = sconn
	return conn, nil
}
1152463
func NewConnector(config Config, scope metrics.Scope) dosa.Connector {
	return &Connector{
		client:    NewRedigoClient(config.ServerSettings, scope),
		ttl:       config.TTL,
		stats:     metrics.CheckIfNilStats(scope),
		keyPrefix: config.KeyPrefix,
	}
}
513549
func (obj *Doc) CreateConnection(ctx context.Context, connection *Connection) (string, error) {
	result := &struct {
		ConnectionId string	`json:"qConnectionId"`
	} {}
	err := obj.rpc(ctx, "CreateConnection", result, connection)
	return result.ConnectionId, err 
}
765810
func (p *Plugin) NewBytesConnection(name string) *mux.BytesConnectionStr {
	return p.mux.NewBytesConnection(name)
}
1186233
func NewConnection(address string, opts *ConnectOpts) (*Connection, error) {
	keepAlivePeriod := defaultKeepAlivePeriod
	if opts.KeepAlivePeriod > 0 {
		keepAlivePeriod = opts.KeepAlivePeriod
	}

	// Connect to Server
	var err error
	var conn net.Conn
	nd := net.Dialer{Timeout: opts.Timeout, KeepAlive: keepAlivePeriod}
	if opts.TLSConfig == nil {
		conn, err = nd.Dial("tcp", address)
	} else {
		conn, err = tls.DialWithDialer(&nd, "tcp", address, opts.TLSConfig)
	}
	if err != nil {
		return nil, RQLConnectionError{rqlError(err.Error())}
	}

	c := newConnection(conn, address, opts)

	// Send handshake
	handshake, err := c.handshake(opts.HandshakeVersion)
	if err != nil {
		return nil, err
	}

	if err = handshake.Send(); err != nil {
		return nil, err
	}

	c.runConnection()

	return c, nil
}
1050607
func NewConnection(bus I2cDevice, address int) (connection *i2cConnection) {
	return &i2cConnection{bus: bus, address: address, mutex: &sync.Mutex{}}
}
416970
func NewCONNECT(opts *CONNECTOptions) (Packet, error) {
	// Initialize the options.
	if opts == nil {
		opts = &CONNECTOptions{}
	}

	// Validate the options.
	if err := opts.validate(); err != nil {
		return nil, err
	}

	// Create a CONNECT Packet.
	p := &CONNECT{
		clientID:     opts.ClientID,
		userName:     opts.UserName,
		password:     opts.Password,
		cleanSession: opts.CleanSession,
		keepAlive:    opts.KeepAlive,
		willTopic:    opts.WillTopic,
		willMessage:  opts.WillMessage,
		willQoS:      opts.WillQoS,
		willRetain:   opts.WillRetain,
	}

	// Set the variable header to the Packet.
	p.setVariableHeader()

	// Set the payload to the Packet.
	p.setPayload()

	// Set the fixed header to the packet.
	p.setFixedHeader()

	// Return the Packet.
	return p, nil
}
1174571
func NewBytesConnection(client Client, log logging.Logger) (*BytesConnectionRedis, error) {
	return &BytesConnectionRedis{log, client, make(chan string), false}, nil
}
1150395
func (c *Transport) createConnection() (*Connection, error) {
	conn, err := dial(c.Version, c.hostAddr, c.tlsConfig)
	if err != nil {
		return nil, driver.WithStack(err)
	}

	// Record connection
	c.connMutex.Lock()
	c.connections = append(c.connections, conn)
	startCleanup := len(c.connections) == 1
	c.connMutex.Unlock()

	if startCleanup {
		// TODO enable cleanup
		go c.cleanup()
	}

	return conn, nil
}