// Connect tests the connection and if successful, connects to the database
Connect tests the connection and if successful, connects to the database
// Connect tests the connection and if successful connects to the database
func (r *Rethinkdb) Connect() error {
	testConn, err := gorethink.Connect(gorethink.ConnectOpts{
		Address: r.uri.Host,
		Timeout: time.Second * 10,
	})
	if err != nil {
		return err
	}
	testConn.Close()
	r.client, err = gorethink.Connect(gorethink.ConnectOpts{
		Address: r.uri.Host,
		MaxIdle: 10,
	})
	if err != nil {
		return err
	}
	r.client.Use(r.database)
	constraint, _ := version.NewConstraint(">= 2.0")
	if err := r.assertServerVersion(constraint); err != nil {
		return err
	}
	return nil
}
func ( r * Rethinkdb ) Connect ( ) error { testConn , err := gorethink . Connect ( gorethink . ConnectOpts { Address : r . uri . Host , Timeout : time . Second * 10 , } ) if err != nil { return err } testConn . Close ( ) r . client , err = gorethink . Connect ( gorethink . ConnectOpts { Address : r . uri . Host , MaxIdle : 10 , } ) if err != nil { return err } r . client . Use ( r . database ) constraint , _ := version . NewConstraint ( " " ) if err := r . assertServerVersion ( constraint ) ; err != nil { return err } return nil }
Connect tests the connection and if successful, connects to the database
Connect tests the connection and if successful connects to the database
// test the connection with a timeout // we don't want a timeout here because we want to keep connections open