Documentation ¶
Overview ¶
Package pool contain an implementation of a connection pool to multiple database pointing to the same instance
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ConnectionProfilePostgresql is the connection profile to be used for PostgreSQL ConnectionProfilePostgresql connectionProfilePostgresql // ConnectionProfilePostgresqlPhysicalReplication is the connection profile to be used for PostgreSQL // using the physical replication protocol ConnectionProfilePostgresqlPhysicalReplication connectionProfilePostgresqlPhysicalReplication // ConnectionProfilePgbouncer is the connection profile to be used for Pgbouncer ConnectionProfilePgbouncer connectionProfilePgbouncer )
Functions ¶
func NewDBConnection ¶ added in v1.19.6
func NewDBConnection(connectionString string, profile ConnectionProfile) (*sql.DB, error)
NewDBConnection creates a postgres connection with the simple protocol
Types ¶
type ConnectionPool ¶
type ConnectionPool struct {
// contains filtered or unexported fields
}
ConnectionPool is a repository of DB connections, pointing to the same instance given a base DSN without the "dbname" parameter
func NewPgbouncerConnectionPool ¶ added in v1.19.6
func NewPgbouncerConnectionPool(baseConnectionString string) *ConnectionPool
NewPgbouncerConnectionPool creates a new connectionMap of connections given the base connection string
func NewPostgresqlConnectionPool ¶ added in v1.19.6
func NewPostgresqlConnectionPool(baseConnectionString string) *ConnectionPool
NewPostgresqlConnectionPool creates a new connectionMap of connections given the base connection string, targeting a PostgreSQL server
func (*ConnectionPool) Connection ¶
func (pool *ConnectionPool) Connection(dbname string) (*sql.DB, error)
Connection gets the connection for the given database
func (*ConnectionPool) GetDsn ¶ added in v1.16.0
func (pool *ConnectionPool) GetDsn(dbname string) string
GetDsn returns the connection string for a given database
func (*ConnectionPool) ShutdownConnections ¶
func (pool *ConnectionPool) ShutdownConnections()
ShutdownConnections closes every database connection
type ConnectionProfile ¶ added in v1.19.6
type ConnectionProfile interface {
// Enrich applies the configuration of the profile to a connection configuration
Enrich(config *pgx.ConnConfig)
}
ConnectionProfile represent a predefined set of connection configuration
type Pooler ¶ added in v1.19.4
type Pooler interface { // Connection gets the connection for the given database Connection(dbname string) (*sql.DB, error) // GetDsn returns the connection string for a given database GetDsn(dbname string) string // ShutdownConnections closes every database connection ShutdownConnections() }
Pooler represents an interface for a connection pooler. It exposes functionalities for retrieving a connection, obtaining the Data Source Name (DSN), and shutting down all active connections.