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 ¶
This section is empty.
Functions ¶
This section is empty.
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 NewConnectionPool ¶
func NewConnectionPool(baseConnectionString string) *ConnectionPool
NewConnectionPool creates a new connectionMap of connections given the base connection string
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 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.