postgres

package
v0.0.0-...-553ec8c Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Postgres) error

Option defines the functional option pattern for configuring Postgres.

func WithConnAttempts

func WithConnAttempts(connAttempts int) Option

WithConnAttempts sets the number of connection attempts.

func WithConnTimeout

func WithConnTimeout(connTimeout time.Duration) Option

WithConnTimeout sets the connection timeout.

func WithLogger

func WithLogger(log logger.Logger) Option

WithLogger sets the logger.

func WithMaxPoolSize

func WithMaxPoolSize(maxSize int) Option

WithMaxPoolSize sets the maximum pool size.

type Postgres

type Postgres struct {
	// Use Pool for better performance if there are no transactions.
	Pool *pgxpool.Pool
	// Use TrManager to work with transactions.
	TrManager *manager.Manager
	// contains filtered or unexported fields
}

Postgres represents a Postgres instance with pool and transaction manager.

func New

func New(ctx context.Context, url string, opts ...Option) (*Postgres, error)

New creates a new Postgres instance with given url and functional options.

func (*Postgres) Close

func (p *Postgres) Close()

Close closes the Postgres pool.

func (*Postgres) GetTransactionConn

func (p *Postgres) GetTransactionConn(ctx context.Context) trmpgx.Tr

Jump to

Keyboard shortcuts

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