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 ¶
- type Storage
- func (s *Storage) Apps() *mgo.Collection
- func (s *Storage) Close()
- func (s *Storage) Collection(name string) *mgo.Collection
- func (s *Storage) ServiceInstances() *mgo.Collection
- func (s *Storage) Services() *mgo.Collection
- func (s *Storage) Teams() *mgo.Collection
- func (s *Storage) Users() *mgo.Collection
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 ¶
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 ¶
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.