Documentation ¶
Index ¶
Constants ¶
View Source
const ( ErrorRowQueryDiffLenght = "only one query per row is allowed" ErrorEmptyRow = "rows cannot be empty" ErrorMultipleQueryForSingleRow = "multiple queries for one row" ErrorMultipleDBM = "only one filter is supported" ErrorReconnecting = "error reconnecting" ErrorIndexEmpty = "index keys cannot be empty" ErrorIndexAlreadyExist = "index already exists with a different name" ErrorIndexComposedTTL = "TTL indexes are single-field indexes, compound indexes do not support TTL" ErrorSessionClosed = "session closed" ErrorRowOptDiffLenght = "only one options per row is allowed" ErrorCollectionNotFound = "collection not found" )
View Source
const (
DEFAULT_CONN_TIMEOUT = 10 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientOpts ¶
type ClientOpts struct { // ConnectionString is the expression used to connect to a storage db server. // It contains parameters such as username, hostname, password and port ConnectionString string // UseSSL is SSL connection is required to connect UseSSL bool // This setting allows the use of self-signed certificates when connecting to an encrypted storage database. SSLInsecureSkipVerify bool // Ignore hostname check when it differs from the original (for example with SSH tunneling). // The rest of the TLS verification will still be performed SSLAllowInvalidHostnames bool // Path to the PEM file with trusted root certificates SSLCAFile string // Path to the PEM file which contains both client certificate and private key. This is required for Mutual TLS. SSLPEMKeyfile string // Sets the session consistency for the storage connection SessionConsistency string // Sets the connection timeout to the database. Defaults to 10s. ConnectionTimeout int // type of database/driver Type string }
func (*ClientOpts) GetTLSConfig ¶
func (opts *ClientOpts) GetTLSConfig() (*tls.Config, error)
GetTLSConfig returns the TLS config given the configuration specified in ClientOpts. It loads certificates if necessary.
type DBTable ¶
type DBTable interface {
TableName() string
}
DBTable is an interface that should be implemented by database models in order to perform CRUD operations
type ObjectID ¶
type ObjectID interface { Hex() string String() string Timestamp() time.Time MarshalJSON() ([]byte, error) UnmarshalJSON([]byte) error MarshalText() ([]byte, error) UnmarshalText([]byte) error }
ObjectID interface to be implemented by each db driver
type PersistentStorage ¶
type PersistentStorage interface { // Insert a DbObject into the database Insert(context.Context, ...id.DBObject) error // Delete a DbObject from the database Delete(context.Context, id.DBObject, ...dbm.DBM) error // Update a DbObject in the database Update(context.Context, id.DBObject, ...dbm.DBM) error // Count counts all rows for a DBTable if no filter dbm.DBM given. // If a filter dbm.DBM is specified it will count the rows given the built query for that filter. // If multiple filters dbm.DBM are specified, it will return an error. // In case of an error, the count result is going to be 0. Count(ctx context.Context, row id.DBObject, filter ...dbm.DBM) (count int, error error) // Query one or multiple DBObjects from the database Query(context.Context, id.DBObject, interface{}, dbm.DBM) error // BulkUpdate updates multiple rows BulkUpdate(context.Context, []id.DBObject, ...dbm.DBM) error // UpdateAll executes the update query dbm.DBM over // the elements filtered by query dbm.DBM in the row id.DBObject collection UpdateAll(ctx context.Context, row id.DBObject, query, update dbm.DBM) error // Drop drops the collection given the TableName() of the id.DBObject Drop(context.Context, id.DBObject) error // CreateIndex creates an index.Index in row id.DBObject TableName() CreateIndex(ctx context.Context, row id.DBObject, index index.Index) error // GetIndexes returns all the index.Index associated to row id.DBObject GetIndexes(ctx context.Context, row id.DBObject) ([]index.Index, error) // Ping checks if the database is reachable Ping(context.Context) error // HasTable checks if the table/collection exists HasTable(context.Context, string) (bool, error) // DropDatabase removes the database DropDatabase(ctx context.Context) error // Migrate creates the table/collection if it doesn't exist Migrate(context.Context, []id.DBObject, ...dbm.DBM) error // DBTableStats retrieves statistics for a specified table in the database. // The function takes a context.Context and an id.DBObject as input parameters, // where the DBObject represents the table to get stats for. // The result is decoded into a dbm.DBM object, along with any error that occurred during the command execution. // Example: stats["capped"] -> true DBTableStats(ctx context.Context, row id.DBObject) (dbm.DBM, error) // Aggregate performs an aggregation query on the row id.DBObject collection // query is the aggregation pipeline to be executed // it returns the aggregation result and an error if any Aggregate(ctx context.Context, row id.DBObject, query []dbm.DBM) ([]dbm.DBM, error) // CleanIndexes removes all the indexes from the row id.DBObject collection CleanIndexes(ctx context.Context, row id.DBObject) error // Upsert performs an upsert operation on the row id.DBObject collection // query is the filter to be used to find the document to update // update is the update to be applied to the document // row is modified with the result of the operation Upsert(ctx context.Context, row id.DBObject, query, update dbm.DBM) error // GetDatabaseInfo returns information of the database to which the driver is connecting to GetDatabaseInfo(ctx context.Context) (utils.Info, error) // GetTables return the list of collections for a given database GetTables(ctx context.Context) ([]string, error) // DropTable drops a table/collection from the database. Returns the number of affected rows and error DropTable(ctx context.Context, name string) (int, error) }
type StorageLifecycle ¶
type StorageLifecycle interface { // Connects to a db instance Connect(*ClientOpts) error // Close cleans up possible resources after we stop using storage driver. Close() error // DBType returns the type of the registered storage driver. DBType() utils.DBType }
Click to show internal directories.
Click to hide internal directories.