db

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Paginate

func Paginate(query *mgo.Query, info *PageInfo) *mgo.Query

Types

type MongoConfig

type MongoConfig struct {
	Logger log.FieldLogger

	// Debug enable the delivery of debug messages to the logger.  Only meaningful
	// if a logger is also set.
	Debug bool
	mgo.DialInfo
}

func (MongoConfig) MarshalJSON

func (config MongoConfig) MarshalJSON() ([]byte, error)

func (MongoConfig) Storable

func (config MongoConfig) Storable() StorableMongoConfig

type MongoStorage

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

func NewMongo

func NewMongo(config MongoConfig) (*MongoStorage, error)

func (*MongoStorage) AddContainerumEvent added in v0.0.4

func (mongo *MongoStorage) AddContainerumEvent(collectionName string, event model.Event) error

func (*MongoStorage) Close

func (mongo *MongoStorage) Close() (err error)

func (*MongoStorage) GetAllChangesList added in v0.0.15

func (mongo *MongoStorage) GetAllChangesList(collectionName string, limit int, startTime time.Time) ([]model.Event, error)

func (*MongoStorage) GetAllEventsList added in v0.0.15

func (mongo *MongoStorage) GetAllEventsList(resourcetype model.ResourceType, limit int, startTime time.Time) ([]model.Event, error)

func (*MongoStorage) GetAllNamespacesChangesList added in v0.0.15

func (mongo *MongoStorage) GetAllNamespacesChangesList(limit int, startTime time.Time) ([]model.Event, error)

func (*MongoStorage) GetChangesInNamespacesList added in v0.1.0

func (mongo *MongoStorage) GetChangesInNamespacesList(collectionName string, limit int, startTime time.Time, namespaces ...string) ([]model.Event, error)

func (*MongoStorage) GetChangesList

func (mongo *MongoStorage) GetChangesList(namespace, resource, collectionName string, limit int, startTime time.Time) ([]model.Event, error)

func (*MongoStorage) GetEventsInNamespacesList added in v0.1.0

func (mongo *MongoStorage) GetEventsInNamespacesList(resourcetype model.ResourceType, limit int, startTime time.Time, namespaces ...string) ([]model.Event, error)

func (*MongoStorage) GetEventsList added in v0.0.2

func (mongo *MongoStorage) GetEventsList(namespace, resource string, resourcetype model.ResourceType, limit int, startTime time.Time) ([]model.Event, error)

func (*MongoStorage) GetNamespacesChangesList added in v0.1.0

func (mongo *MongoStorage) GetNamespacesChangesList(limit int, startTime time.Time, namespaces ...string) ([]model.Event, error)

func (*MongoStorage) GetSystemEventsList added in v0.0.4

func (mongo *MongoStorage) GetSystemEventsList(limit int, startTime time.Time) ([]model.Event, error)

func (*MongoStorage) GetUsersEventsList added in v0.0.4

func (mongo *MongoStorage) GetUsersEventsList(limit int, startTime time.Time) ([]model.Event, error)

func (*MongoStorage) IsClosed

func (mongo *MongoStorage) IsClosed() bool

type PageInfo

type PageInfo struct {
	PerPage        int
	Page           int
	DefaultPerPage int
}

func (PageInfo) Init

func (pages PageInfo) Init() (limit, offset int)

type PipErr

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

func (PipErr) Apply

func (piperr PipErr) Apply(op func(error) error) PipErr

func (PipErr) Extract

func (piperr PipErr) Extract() error

func (PipErr) NotFoundToNil

func (piperr PipErr) NotFoundToNil() PipErr

func (PipErr) ToMongerr

func (piperr PipErr) ToMongerr() PipErr

type StorableMongoConfig

type StorableMongoConfig struct {
	// Debug enable the delivery of debug messages to the logger.  Only meaningful
	// if a logger is also set.
	Debug bool `json:"debug"`

	// Addrs holds the addresses for the seed servers.
	Addrs []string `json:"addrs"`

	// Timeout is the amount of time to wait for a server to respond when
	// first connecting and on follow up operations in the session. If
	// timeout is zero, the call may block forever waiting for a connection
	// to be established. Timeout does not affect logic in DialServer.
	Timeout time.Duration `json:"timeout"`

	// Database is the default database name used when the Session.DB method
	// is called with an empty name, and is also used during the initial
	// authentication if Source is unset.
	Database string `json:"database"`

	// ReplicaSetName, if specified, will prevent the obtained session from
	// communicating with any server which is not part of a replica set
	// with the given name. The default is to communicate with any server
	// specified or discovered via the servers contacted.
	ReplicaSetName string `json:"replica_set_name"`

	// Source is the database used to establish credentials and privileges
	// with a MongoDB server. Defaults to the value of Database, if that is
	// set, or "admin" otherwise.
	Source string `json:"source"`

	// Service defines the service name to use when authenticating with the GSSAPI
	// mechanism. Defaults to "mongodb".
	Service string `json:"service"`

	// ServiceHost defines which hostname to use when authenticating
	// with the GSSAPI mechanism. If not specified, defaults to the MongoDB
	// server's address.
	ServiceHost string `json:"service_host"`

	// Mechanism defines the protocol for credential negotiation.
	// Defaults to "MONGODB-CR".
	Mechanism string `json:"mechanism"`

	// Username and Password inform the credentials for the initial authentication
	// done on the database defined by the Source field. See Session.Login.
	Username string `json:"username"`
	Password string `json:"password"`

	// PoolLimit defines the per-server socket pool limit. Defaults to 4096.
	// See Session.SetPoolLimit for details.
	PoolLimit int `json:"pool_limit"`

	// PoolTimeout defines max time to wait for a connection to become available
	// if the pool limit is reaqched. Defaults to zero, which means forever.
	// See Session.SetPoolTimeout for details
	PoolTimeout time.Duration `json:"pool_timeout"`

	// The identifier of the client application which ran the operation.
	AppName string `json:"app_name"`

	// ReadPreference defines the manner in which servers are chosen. See
	// Session.SetMode and Session.SelectServers.
	ReadPreference *mgo.ReadPreference `json:"read_preference,omitempty"`

	// FailFast will cause connection and query attempts to fail faster when
	// the server is unavailable, instead of retrying until the configured
	// timeout period. Note that an unavailable server may silently drop
	// packets instead of rejecting them, in which case it's impossible to
	// distinguish it from a slow server, so the timeout stays relevant.
	FailFast bool `json:"fail_fast"`

	// Direct informs whether to establish connections only with the
	// specified seed servers, or to obtain information for the whole
	// cluster and establish connections with further servers too.
	Direct bool `json:"direct"`

	// MinPoolSize defines The minimum number of connections in the connection pool.
	// Defaults to 0.
	MinPoolSize int `json:"min_pool_size"`

	//The maximum number of milliseconds that a connection can remain idle in the pool
	// before being removed and closed.
	MaxIdleTimeMS int `json:"max_idle_time_ms"`
}

Jump to

Keyboard shortcuts

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