tempdb
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
Constants¶
const (DefaultOnInstanceDbPrefix = "pgschemadiff_tmp_"DefaultOnInstanceMetadataSchema = "pgschemadiff_tmp_metadata"DefaultOnInstanceMetadataTable = "metadata"DefaultStatementTimeout = 3 *time.Second)
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeContextualCloser¶added inv0.6.0
typeCreateConnPoolForDbFn¶added inv0.8.0
typeDatabase¶added inv0.6.0
type Database struct {// ConnPool is the connection pool to the temporary databaseConnPool *sql.DB// ExcludeMetadataOptions are the options used to exclude any internal metadata from plan generationExcludeMetadataOptions []schema.GetSchemaOpt// ContextualCloser should be called to clean up the temporary databaseContextualCloser}
Database represents a temporary database. It should be closed when it is no longer needed.
typeFactory¶
type Factory interface {// Create creates a temporary database. Be sure to always call the ContextualCloser to ensure the database and// connections are cleaned upCreate(ctxcontext.Context) (*Database,error)io.Closer}
Factory is used to create temp databases These databases do not have to be in-memory. They might be, for example,be created on the target Postgres server
funcNewOnInstanceFactory¶
func NewOnInstanceFactory(ctxcontext.Context, createConnPoolForDbCreateConnPoolForDbFn, opts ...OnInstanceFactoryOpt) (_Factory, _retErrerror)
NewOnInstanceFactory provides an implementation to easily create temporary databases on the Postgres instanceconnected to via CreateConnPoolForDbFn. The Postgres instance is connected to via the "postgres" database, and thentemporary databases are created using that connection. These temporary databases are also connected to via theCreateConnPoolForDbFn.Make sure to always call Close() on the returned Factory to ensure the root connection is closed
WARNING:It is possible this will lead to orphaned temporary databases. These orphaned databases should be pretty small ifthey're only being used by the pg-schema-diff library, but it's recommended to clean them up when possible. This canbe done by deleting all old databases with the provided temp db prefix. The metadata table can be inspected to findwhen the temporary database was created, e.g., to create a TTL
typeOnInstanceFactoryOpt¶
type OnInstanceFactoryOpt func(*onInstanceFactoryOptions)
funcWithDbPrefix¶
func WithDbPrefix(prefixstring)OnInstanceFactoryOpt
WithDbPrefix sets the prefix for the temp database name
funcWithLogger¶
func WithLogger(loggerlog.Logger)OnInstanceFactoryOpt
WithLogger sets the logger for the factory. If not set, a SimpleLogger will be used
funcWithMetadataSchema¶
func WithMetadataSchema(schemastring)OnInstanceFactoryOpt
WithMetadataSchema sets the prefix for the schema name containing the metadata
funcWithMetadataTable¶
func WithMetadataTable(tablestring)OnInstanceFactoryOpt
WithMetadataTable sets the metadata table name
funcWithRootDatabase¶added inv0.5.0
func WithRootDatabase(dbstring)OnInstanceFactoryOpt
WithRootDatabase sets the database to connect to when creating temporary databases