Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Host string `json:"host" yaml:"host" validate:"required"`
Port string `json:"port" yaml:"port" validate:"required"`
DB string `json:"db" yaml:"db" validate:"required"`
User string `json:"user" yaml:"user" validate:"required"`
Password string `json:"password" yaml:"password" validate:"required"`
AppName string `json:"app-name" yaml:"app-name"`
MaxOpenConn int32 `json:"max-open-conn" yaml:"max-open-conn"`
MaxConnLifetime gduration.Duration `json:"max-conn-life-time" yaml:"max-conn-life-time"`
MaxConnIdleTime gduration.Duration `json:"max-conn-idle-time" yaml:"max-conn-idle-time"`
Options string `json:"options" yaml:"options"`
SSLMode string `json:"sslmode" yaml:"sslmode"` // disable | require | verify-ca | verify-full
ConnectTimeout gduration.Duration `json:"connect-timeout" yaml:"connect-timeout"` // per-connection timeout
MinConns int32 `json:"min-conns" yaml:"min-conns"`
}
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a connection handle that owns a pgx pool and a database/sql view of it. Use Pool for pgx-native access and SQL for database/sql access (migrations, tools). The handle owns both: call Close once to release everything. Do not close the values returned by Pool or SQL directly.
func New ¶
New opens a pgx connection pool from config, applies the pool tuning options, verifies connectivity with a ping, and returns an owning DB handle.
func (*DB) Close ¶
Close releases the pool and the database/sql handle. It is safe to call more than once; subsequent calls are no-ops.
Click to show internal directories.
Click to hide internal directories.