func (c *Connection) Connect() error {
	dsn := MakeDSN(c.params)
	c.logger.WithFields(logrus.Fields{"dsn": dsn}).Info("connecting to the DB")
	var err error
	var db *sqlx.DB
	for i := 0; i < maxDBConnectAttempts; i++ {
		db, err = sqlx.Connect(c.dialect, dsn)
		if err == nil {
			break
		}
		secondsToWait := i + 1
		c.logger.Log().Warningf("Attempt %d - could not connect to database...retry in %d seconds: %s", i, secondsToWait, err)
		time.Sleep(time.Duration(secondsToWait) * time.Second)
	}

	if err != nil {
		c.logger.WithFields(logrus.Fields{"dsn": dsn}).Info("DB connection failed")
		return err
	}
	c.DB = db
	return nil
}
// Connect initiates a connection to the database server defined in c.params.
Connect initiates a connection to the database server defined in c.params.
// Connect initiates a connection to the database server defined in c . params .
func (c *Connection) Connect() error {
	dsn := MakeDSN(c.params)
	c.logger.WithFields(logrus.Fields{"dsn": dsn}).Info("connecting to the DB")
	var err error
	var db *sqlx.DB
	for i := 0; i < maxDBConnectAttempts; i++ {
		db, err = sqlx.Connect(c.dialect, dsn)
		if err == nil {
			break
		}
		secondsToWait := i + 1
		c.logger.Log().Warningf("Attempt %d - could not connect to database...retry in %d seconds: %s", i, secondsToWait, err)
		time.Sleep(time.Duration(secondsToWait) * time.Second)
	}
	if err != nil {
		c.logger.WithFields(logrus.Fields{"dsn": dsn}).Info("DB connection failed")
		return err
	}
	c.DB = db
	return nil
}
func ( c * Connection ) Connect ( ) error { dsn := MakeDSN ( c . params ) c . logger . WithFields ( logrus . Fields { " " : dsn } ) . Info ( " " ) var err error var db * sqlx . DB for i := 0 ; i < maxDBConnectAttempts ; i ++ { db , err = sqlx . Connect ( c . dialect , dsn ) if err == nil { break } secondsToWait := i + 1 c . logger . Log ( ) . Warningf ( " " , i , secondsToWait , err ) time . Sleep ( time . Duration ( secondsToWait ) * time . Second ) } if err != nil { c . logger . WithFields ( logrus . Fields { " " : dsn } ) . Info ( " " ) return err } c . DB = db return nil }
Connect initiates a connection to the database server defined in c.params.
Connect initiates a connection to the database server defined in c . params .