stdpool

package
v0.0.0-...-4dcfcdd Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package stdpool creates standardized database connection pools.

Package stdpool creates standardized database connection pools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CockroachMinVersion

func CockroachMinVersion(version string, minVersion string) (bool, error)

CockroachMinVersion returns true if the CockroachDB version string is at least the specified minimum.

func CockroachSemver

func CockroachSemver(version string) (string, bool)

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

func WithConnectionLifetime(maxLifetime, maxIdle, jitter time.Duration) Option

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

func WithMetrics(pool string) Option

WithMetrics publishes prometheus metrics, using the given pool name.

func WithPoolSize

func WithPoolSize(size int) Option

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

func WithTransactionTimeout(d time.Duration) Option

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.

Jump to

Keyboard shortcuts

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