db

package
v0.0.0-...-e22f67b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2013 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package db encapsulates tsuru connection with MongoDB.

The function Open dials to MongoDB and returns a connection (represented by the Storage type). It manages an internal pool of connections, and reconnects in case of failures. That means that you should not store references to the connection, but always call Open.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage holds the connection with the database.

func Conn

func Conn() (*Storage, error)

Conn reads the tsuru config and calls Open to get a database connection.

Most tsuru packages should probably use this function. Open is intended for use when supporting more than one database.

func Open

func Open(addr, dbname string) (storage *Storage, err error)

Open dials to the MongoDB database, and return the connection (represented by the type Storage).

addr is a MongoDB connection URI, and dbname is the name of the database.

This function returns a pointer to a Storage, or a non-nil error in case of any failure.

func (*Storage) Apps

func (s *Storage) Apps() *mgo.Collection

Apps returns the apps collection from MongoDB.

func (*Storage) Close

func (s *Storage) Close()

Close closes the storage, releasing the connection.

func (*Storage) Collection

func (s *Storage) Collection(name string) *mgo.Collection

Collection returns a collection by its name.

If the collection does not exist, MongoDB will create it.

func (*Storage) ServiceInstances

func (s *Storage) ServiceInstances() *mgo.Collection

ServiceInstances returns the services_instances collection from MongoDB.

func (*Storage) Services

func (s *Storage) Services() *mgo.Collection

Services returns the services collection from MongoDB.

func (*Storage) Teams

func (s *Storage) Teams() *mgo.Collection

Teams returns the teams collection from MongoDB.

func (*Storage) Users

func (s *Storage) Users() *mgo.Collection

Users returns the users collection from MongoDB.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL