postgres

package
v0.0.0-...-c46c504 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	URL          string
	MaxPoolSize  int
	ConnAttempts int
	ConnTimeout  time.Duration
}

func FromAppConfig

func FromAppConfig(appCfg *config.AppConfig) Config

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, cfg Config, logger logger.Logger) (*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