postgres

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnectionPool

func NewConnectionPool(ctx context.Context, connString string, opts ...ConnectionPoolOption) (*sql.DB, error)

NewConnectionPool creates a new connection pool for Postgres using the provided connection string.

The connection string uses standard Postgres format: `postgres://user:password@host:port/database?sslmode=disable`.

It returns a sql.DB instance that can be used to interact with the database.

The function accepts optional configuration options to customize the connection pool.

Types

type ConnectionPoolOption

type ConnectionPoolOption func(config *pgxpool.Config)

ConnectionPoolOption is a function type that modifies the pgxpool.Config for a Postgres connection pool.

func WithHealthCheckPeriod

func WithHealthCheckPeriod(d time.Duration) ConnectionPoolOption

WithHealthCheckPeriod sets the interval for health checks on connections in the pool.

func WithMaxConnIdleTime

func WithMaxConnIdleTime(d time.Duration) ConnectionPoolOption

WithMaxConnIdleTime sets the maximum idle time of a connection in the pool.

func WithMaxConnLifetime

func WithMaxConnLifetime(d time.Duration) ConnectionPoolOption

WithMaxConnLifetime sets the maximum lifetime of a connection in the pool.

func WithMaxConnLifetimeJitter

func WithMaxConnLifetimeJitter(d time.Duration) ConnectionPoolOption

WithMaxConnLifetimeJitter sets the maximum lifetime jitter for connections in the pool.

func WithMaxConnections

func WithMaxConnections(max int32) ConnectionPoolOption

WithMaxConnections sets the maximum number of connections in the pool.

func WithMinConnections

func WithMinConnections(min int32) ConnectionPoolOption

WithMinConnections sets the minimum number of connections in the pool.

func WithMinIdleConnections

func WithMinIdleConnections(min int32) ConnectionPoolOption

WithMinIdleConnections sets the minimum number of idle connections in the pool.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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