tsuru: github.com/globocom/tsuru/db Index | Files | Directories

package db

import "github.com/globocom/tsuru/db"

Package db encapsulates tsuru connection with MongoDB.

The function Conn dials to MongoDB using data from the configuration file and returns a connection (represented by the storage.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.


Package Files



const (
    DefaultDatabaseURL  = ""
    DefaultDatabaseName = "tsuru"

func DbConfig Uses

func DbConfig(prefix string) (string, string)

type LogStorage Uses

type LogStorage struct {

func LogConn Uses

func LogConn() (*LogStorage, error)

func (*LogStorage) AppLogCollection Uses

func (s *LogStorage) AppLogCollection(appName string) *storage.Collection

AppLogCollection returns the logs collection for one app from MongoDB.

func (*LogStorage) CreateAppLogCollection Uses

func (s *LogStorage) CreateAppLogCollection(appName string) (*storage.Collection, error)

CreateAppLogCollection creates a new capped collection to store logs for an app.

func (*LogStorage) LogsCollections Uses

func (s *LogStorage) LogsCollections() ([]*storage.Collection, error)

LogsCollections returns logs collections for all apps from MongoDB.

type Storage Uses

type Storage struct {

func Conn Uses

func Conn() (*Storage, error)

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 (*Storage) Apps Uses

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

Apps returns the apps collection from MongoDB.

func (*Storage) EventBlocks Uses

func (s *Storage) EventBlocks() *storage.Collection

func (*Storage) Events Uses

func (s *Storage) Events() *storage.Collection

func (*Storage) InstallHosts Uses

func (s *Storage) InstallHosts() *storage.Collection

func (*Storage) Limiter Uses

func (s *Storage) Limiter() *storage.Collection

func (*Storage) PasswordTokens Uses

func (s *Storage) PasswordTokens() *storage.Collection

func (*Storage) Pools Uses

func (s *Storage) Pools() *storage.Collection

Pools returns the pool collection.

func (*Storage) PoolsConstraints Uses

func (s *Storage) PoolsConstraints() *storage.Collection

PoolsConstraints return the pool constraints collection.

func (*Storage) Roles Uses

func (s *Storage) Roles() *storage.Collection

func (*Storage) SAMLRequests Uses

func (s *Storage) SAMLRequests() *storage.Collection

SAMLRequests returns the saml_requests from MongoDB.

func (*Storage) ServiceInstances Uses

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

ServiceInstances returns the services_instances collection from MongoDB.

func (*Storage) Services Uses

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

Services returns the services collection from MongoDB.

func (*Storage) Tokens Uses

func (s *Storage) Tokens() *storage.Collection

func (*Storage) UserActions Uses

func (s *Storage) UserActions() *storage.Collection

func (*Storage) Users Uses

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

Users returns the users collection from MongoDB.

func (*Storage) VolumeBinds Uses

func (s *Storage) VolumeBinds() *storage.Collection

func (*Storage) Volumes Uses

func (s *Storage) Volumes() *storage.Collection


dbtestPackage dbtest provides utilities test functions and types for interacting with the database during tests.

Package db imports 5 packages (graph) and is imported by 39 packages. Updated 2019-02-01. Refresh now. Tools for package owners.