Documentation ¶
Index ¶
- Variables
- func Configure(ctx context.Context, db ConfigurableDB, dbName string, mon *monkit.Scope)
- func EscapableCommaSplit(val string) []string
- func ParseDBMapping(urlSpec string) (map[string]string, error)
- func SchemeForImplementation(implementation Implementation) string
- type ConfigurableDB
- type Implementation
- type NullTime
- type TempDatabase
Constants ¶
This section is empty.
Variables ¶
var ErrNullTime = errs.Class("null time error")
ErrNullTime defines error class for NullTime.
Functions ¶
func Configure ¶
func Configure(ctx context.Context, db ConfigurableDB, dbName string, mon *monkit.Scope)
Configure Sets Connection Boundaries and adds db_stats monitoring to monkit.
func EscapableCommaSplit ¶ added in v1.18.1
EscapableCommaSplit is like strings.Split(x, ","), but if it sees two ','s in a row, it will treat them like one unsplit comma. So "hello,there,,friend" will result in ["hello", "there,friend"].
func ParseDBMapping ¶ added in v1.18.1
ParseDBMapping parses a mapping of database connection URLs, preceded by the default URL. An example that overrides the repairqueue looks like: cockroach://user:pw@host/database,repairqueue:postgres://user:pw@host/database. The default is stored in "".
func SchemeForImplementation ¶ added in v0.29.0
func SchemeForImplementation(implementation Implementation) string
SchemeForImplementation returns the scheme that is used for URLs that use the given Implementation.
Types ¶
type ConfigurableDB ¶ added in v0.31.0
type ConfigurableDB interface { SetMaxIdleConns(int) SetMaxOpenConns(int) SetConnMaxLifetime(time.Duration) Stats() sql.DBStats }
ConfigurableDB contains methods for configuring a database.
type Implementation ¶ added in v0.27.0
type Implementation int
Implementation type of valid DBs.
const ( // Unknown is an unknown db type. Unknown Implementation = iota // Postgres is a Postgresdb type. Postgres // Cockroach is a Cockroachdb type. Cockroach // Bolt is a Bolt kv store. Bolt // Redis is a Redis kv store. Redis // SQLite3 is a sqlite3 database. SQLite3 )
func ImplementationForScheme ¶ added in v0.27.0
func ImplementationForScheme(scheme string) Implementation
ImplementationForScheme returns the Implementation that is used for the url with the provided scheme.
func SplitConnStr ¶ added in v0.27.0
func SplitConnStr(s string) (driver string, source string, implementation Implementation, err error)
SplitConnStr returns the driver and DSN portions of a URL, along with the db implementation.
type NullTime ¶
NullTime time helps convert nil to time.Time.
type TempDatabase ¶ added in v0.27.0
type TempDatabase struct { tagsql.DB ConnStr string Schema string Driver string Implementation Implementation Cleanup func(tagsql.DB) error }
TempDatabase is a database (or something that works like an isolated database, such as a PostgreSQL schema) with a semi-unique name which will be cleaned up when closed. Mainly useful for testing purposes.
func (*TempDatabase) Close ¶ added in v0.27.0
func (db *TempDatabase) Close() error
Close closes the database and deletes the schema.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package dbschema package implements querying and comparing schemas for testing.
|
Package dbschema package implements querying and comparing schemas for testing. |
Package pgutil contains utilities for postgres
|
Package pgutil contains utilities for postgres |
pgerrcode
Package pgerrcode implements postgres error extraction without depending on a postgres library.
|
Package pgerrcode implements postgres error extraction without depending on a postgres library. |
Package txutil provides safe transaction-encapsulation functions which have retry semantics as necessary.
|
Package txutil provides safe transaction-encapsulation functions which have retry semantics as necessary. |