Exemple #1
0
func LogConn() (*LogStorage, error) {
	var (
		strg LogStorage
		err  error
	)
	url, dbname := dbConfig("logdb-")
	strg.Storage, err = storage.Open(url, dbname)
	return &strg, err
}
Exemple #2
0
// Conn reads the tsuru config and calls storage.Open to get a database connection.
//
// Most tsuru packages should probably use this function. storage.Open is intended for
// use when supporting more than one database.
func Conn() (*Storage, error) {
	var (
		strg Storage
		err  error
	)
	url, dbname := dbConfig("")
	strg.Storage, err = storage.Open(url, dbname)
	return &strg, err
}
Exemple #3
0
// conn reads the gandalf config and calls storage.Open to get a database connection.
//
// Most gandalf packages should probably use this function. storage.Open is intended for
// use when supporting more than one database.
func conn() (*storage.Storage, error) {
	url, _ := config.GetString("database:url")
	if url == "" {
		url = DefaultDatabaseURL
	}
	dbname, _ := config.GetString("database:name")
	if dbname == "" {
		dbname = DefaultDatabaseName
	}
	return storage.Open(url, dbname)
}
Exemple #4
0
func conn() (*storage.Storage, error) {
	databaseHost, _ := config.GetString("database:host")
	if databaseHost == "" {
		databaseHost = DefaultDatabaseHost
	}

	databaseName, _ := config.GetString("database:name")
	if databaseName == "" {
		databaseName = DefaultDatabaseName
	}

	return storage.Open(databaseHost, databaseName)
}
Exemple #5
0
func (m *Mongore) openSession() *storage.Storage {
	if m.config.Host == "" {
		m.config.Host = DefaultDatabaseHost
	}
	if m.config.DatabaseName == "" {
		m.config.DatabaseName = DefaultDatabaseName
	}

	s, err := storage.Open(m.config.Host, m.config.DatabaseName)
	if err != nil {
		panic(fmt.Sprintf("Error while establishing connection to MongoDB: %s", err.Error()))
		return nil
	}
	return s
}
Exemple #6
0
// conn reads the gandalf config and calls storage.Open to get a database connection.
//
// Most gandalf packages should probably use this function. storage.Open is intended for
// use when supporting more than one database.
func conn() (*storage.Storage, error) {
	url, dbname := DbConfig()
	return storage.Open(url, dbname)
}