Documentation ¶
Overview ¶
Package stdpool creates standardized database connection pools.
Package stdpool creates standardized database connection pools.
Index ¶
- func CockroachMinVersion(version string, minVersion string) (bool, error)
- func CockroachSemver(version string) (string, bool)
- func OpenMySQLAsTarget(ctx *stopper.Context, connectString string, url *url.URL, options ...Option) (*types.TargetPool, error)
- func OpenOracleAsTarget(ctx *stopper.Context, connectString string, options ...Option) (*types.TargetPool, error)
- func OpenPgxAsConn(ctx *stopper.Context, connectString string, options ...Option) (*pgx.Conn, error)
- func OpenPgxAsStaging(ctx *stopper.Context, connectString string, options ...Option) (*types.StagingPool, error)
- func OpenPgxAsTarget(ctx *stopper.Context, connectString string, options ...Option) (*types.TargetPool, error)
- func OpenTarget(ctx *stopper.Context, connectString string, options ...Option) (*types.TargetPool, error)
- type Option
- func WithConnectionLifetime(maxLifetime, maxIdle, jitter time.Duration) Option
- func WithDiagnostics(diags *diag.Diagnostics, label string) Option
- func WithMetrics(pool string) Option
- func WithPoolSize(size int) Option
- func WithTestControls(tc TestControls) Option
- func WithTransactionTimeout(d time.Duration) Option
- type TestControls
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CockroachMinVersion ¶
CockroachMinVersion returns true if the CockroachDB version string is at least the specified minimum.
func CockroachSemver ¶
CockroachSemver extracts the semantic version string from a cluster's reported version.
func OpenMySQLAsTarget ¶
func OpenMySQLAsTarget( ctx *stopper.Context, connectString string, url *url.URL, options ...Option, ) (*types.TargetPool, error)
OpenMySQLAsTarget opens a database connection, returning it as a single connection.
func OpenOracleAsTarget ¶
func OpenOracleAsTarget( ctx *stopper.Context, connectString string, options ...Option, ) (*types.TargetPool, error)
OpenOracleAsTarget returns an unsupported error.
func OpenPgxAsConn ¶
func OpenPgxAsConn( ctx *stopper.Context, connectString string, options ...Option, ) (*pgx.Conn, error)
OpenPgxAsConn uses pgx to open a database connection, returning it as a single connection.
func OpenPgxAsStaging ¶
func OpenPgxAsStaging( ctx *stopper.Context, connectString string, options ...Option, ) (*types.StagingPool, error)
OpenPgxAsStaging uses pgx to open a database connection, returning it as a types.StagingPool.
func OpenPgxAsTarget ¶
func OpenPgxAsTarget( ctx *stopper.Context, connectString string, options ...Option, ) (*types.TargetPool, error)
OpenPgxAsTarget uses pgx to open a database connection, returning it as a stdlib pool.
func OpenTarget ¶
func OpenTarget( ctx *stopper.Context, connectString string, options ...Option, ) (*types.TargetPool, error)
OpenTarget selects from target connector implementations based on the URL scheme contained in the connection string.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option abstracts over driver-specific configuration.
func WithConnectionLifetime ¶
WithConnectionLifetime configures a connection lifetimes.
func WithDiagnostics ¶
func WithDiagnostics(diags *diag.Diagnostics, label string) Option
WithDiagnostics attaches information about the pool to the given diag.Diagnostics collector.
func WithMetrics ¶
WithMetrics publishes prometheus metrics, using the given pool name.
func WithPoolSize ¶
WithPoolSize sets the nominal size of the database pool.
func WithTestControls ¶
func WithTestControls(tc TestControls) Option
WithTestControls allows certain behaviors to be tweaked for testing.
func WithTransactionTimeout ¶
WithTransactionTimeout imposes a best-effort attempt at limiting the duration of any given database transaction.
type TestControls ¶
type TestControls struct { // WaitForStartup makes certain connection or authentication errors // result in a delay and retry, instead of failing. WaitForStartup bool }
TestControls allows certain behaviors to be tweaked for testing.