postgres

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateConfig

func CreateConfig(
	connectionConfig *ConnectionConfig,
	poolConfig *PoolConfig,
) (*pgxpool.Config, error)

CreateConfig creates pgxpool.Config from ConnectionConfig and PoolConfig (if exists)

Returns error if connectionConfig is nil

Types

type ConnectionConfig

type ConnectionConfig struct {
	Host     string `form:"host"`
	Port     string `form:"port"`
	DbName   string `form:"dbname"`
	User     string `form:"user"`
	Password string `form:"password"`
	SslMode  string `form:"sslmode"`
}

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

func NewPgConnector

func NewPgConnector(
	config *pgxpool.Config,
	pingTimeout time.Duration,
	connectTimeout time.Duration,
) (*Connector, error)

func (*Connector) CloseConnection

func (p *Connector) CloseConnection()

func (*Connector) GetPool

func (p *Connector) GetPool() *pgxpool.Pool

func (*Connector) Ping

func (p *Connector) Ping() error

type PgConnector

type PgConnector interface {
	GetPool() *pgxpool.Pool
	CloseConnection()
	Ping() error
}

type PoolConfig

type PoolConfig struct {
	MaxOpenConns          int           `form:"pool_max_open_conns"`
	MaxIdleConns          int           `form:"pool_max_idle_conns"`
	MaxConnLifetime       time.Duration `form:"pool_max_conn_lifetime"`
	MaxConnIdleTime       time.Duration `form:"pool_max_conn_idle_time"`
	HealthCheckPeriod     time.Duration `form:"pool_health_check_period"`
	MaxConnLifetimeJitter time.Duration `form:"pool_max_conn_lifetime_jitter"`
}

Jump to

Keyboard shortcuts

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