MCPcopy
hub / github.com/jackc/pgx / GetPoolConnector

Function GetPoolConnector

stdlib/sql.go:214–226  ·  view source on GitHub ↗

GetPoolConnector creates a new driver.Connector from the given *pgxpool.Pool. By using this be sure to set the maximum idle connections of the *sql.DB created with this connector to zero since they must be managed from the *pgxpool.Pool. This is required to avoid acquiring all the connections from t

(pool *pgxpool.Pool, opts ...OptionOpenDB)

Source from the content-addressed store, hash-verified

212// *pgxpool.Pool. This is required to avoid acquiring all the connections from the pgxpool and starving any direct
213// users of the pgxpool.
214func GetPoolConnector(pool *pgxpool.Pool, opts ...OptionOpenDB) driver.Connector {
215 c := connector{
216 pool: pool,
217 ResetSession: func(context.Context, *pgx.Conn) error { return nil }, // noop reset session by default
218 driver: pgxDriver,
219 }
220
221 for _, opt := range opts {
222 opt(&c)
223 }
224
225 return c
226}
227
228func OpenDB(config pgx.ConnConfig, opts ...OptionOpenDB) *sql.DB {
229 c := GetConnector(config, opts...)

Callers 1

OpenDBFromPoolFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected