dbpool_pg

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const SERVICE_TYPE = "dbpool_pg"

for single service module, module name equals service name

Variables

This section is empty.

Functions

func Register added in v0.3.0

func Register()

func ServiceFactory added in v0.3.0

func ServiceFactory(params map[string]any) any

Types

type Config added in v0.2.4

type Config struct {
	DSN      string `json:"dsn" yaml:"dsn"`
	Host     string `json:"host" yaml:"host"`
	Port     int    `json:"port" yaml:"port"`
	Database string `json:"database" yaml:"database"`
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`

	MinConns    int           `json:"min-cons" yaml:"min-cons"`
	MaxConns    int           `json:"max-cons" yaml:"max-cons"`
	MaxIdleTime time.Duration `json:"max-idle-time" yaml:"max-idle-time"`
	MaxLifetime time.Duration `json:"max-lifetime" yaml:"max-lifetime"`
	SSLMode     string        `json:"sslmode" yaml:"sslmode"`

	Schema     string            `json:"schema" yaml:"schema"`
	RlsContext map[string]string `json:"rls-context" yaml:"rls-context"`
}

Config represents the configuration for the PostgreSQL connection pool service. It can be provided in various formats, including a DSN string, a map, or a struct. If using DSN, it should be in the format: postgres://username:password@host:port/database?sslmode=disable&pool_min_conns=0&pool_max_conns=4&pool_max_conn_idle_time=30m&pool_max_conn_lifetime=1h Host, Port, Database, Username, and Password can be provided separately if DSN is not used. Other parameters like MinConnections, MaxConnections, MaxIdleTime, MaxLifetime, and SSLMode can also be set.

func (*Config) GetFinalDSN added in v0.3.0

func (cfg *Config) GetFinalDSN() string

type PgxPostgresPool added in v0.9.3

type PgxPostgresPool struct {
	Dsn        string
	Schema     string
	RlsContext map[string]string
	// contains filtered or unexported fields
}

func NewPgxPostgresPool

func NewPgxPostgresPool(poolName string, dsn string, schema string, rlsContext map[string]string) (*PgxPostgresPool, error)

func Service added in v0.3.0

func Service(poolName string, cfg *Config) *PgxPostgresPool

func (*PgxPostgresPool) Acquire added in v0.9.3

func (*PgxPostgresPool) Begin added in v0.9.3

Begin implements serviceapi.DbPool.

func (*PgxPostgresPool) Exec added in v0.9.3

func (p *PgxPostgresPool) Exec(ctx context.Context, query string, args ...any) (serviceapi.CommandResult, error)

Exec implements serviceapi.DbPool.

func (*PgxPostgresPool) IsErrorNoRows added in v0.9.3

func (p *PgxPostgresPool) IsErrorNoRows(err error) bool

IsErrorNoRows implements serviceapi.DbPool.

func (*PgxPostgresPool) IsExists added in v0.9.3

func (p *PgxPostgresPool) IsExists(ctx context.Context, query string, args ...any) (bool, error)

IsExists implements serviceapi.DbPool.

func (*PgxPostgresPool) Ping added in v0.9.3

func (p *PgxPostgresPool) Ping(ctx context.Context) error

Ping implements serviceapi.DbPool.

func (*PgxPostgresPool) Query added in v0.9.3

func (p *PgxPostgresPool) Query(ctx context.Context, query string, args ...any) (serviceapi.Rows, error)

Query implements serviceapi.DbPool.

func (*PgxPostgresPool) QueryRow added in v0.9.3

func (p *PgxPostgresPool) QueryRow(ctx context.Context, query string, args ...any) serviceapi.Row

QueryRow implements serviceapi.DbPool.

func (*PgxPostgresPool) Release added in v0.9.3

func (p *PgxPostgresPool) Release() error

Release implements serviceapi.DbPool.

func (*PgxPostgresPool) SelectManyRowMap added in v0.9.3

func (p *PgxPostgresPool) SelectManyRowMap(ctx context.Context, query string, args ...any) ([]serviceapi.RowMap, error)

SelectManyRowMap implements serviceapi.DbPool.

func (*PgxPostgresPool) SelectManyWithMapper added in v0.9.3

func (p *PgxPostgresPool) SelectManyWithMapper(ctx context.Context, fnScan func(serviceapi.Row) (any, error), query string, args ...any) (any, error)

SelectManyWithMapper implements serviceapi.DbPool.

func (*PgxPostgresPool) SelectMustOne added in v0.9.3

func (p *PgxPostgresPool) SelectMustOne(ctx context.Context, query string, args []any, dest ...any) error

SelectMustOne implements serviceapi.DbPool.

func (*PgxPostgresPool) SelectOne added in v0.9.3

func (p *PgxPostgresPool) SelectOne(ctx context.Context, query string, args []any, dest ...any) error

SelectOne implements serviceapi.DbPool.

func (*PgxPostgresPool) SelectOneRowMap added in v0.9.3

func (p *PgxPostgresPool) SelectOneRowMap(ctx context.Context, query string, args ...any) (serviceapi.RowMap, error)

SelectOneRowMap implements serviceapi.DbPool.

func (*PgxPostgresPool) SetSchemaRls added in v0.9.3

func (p *PgxPostgresPool) SetSchemaRls(schema string, rlsContext map[string]string)

SetSchemaRls implements serviceapi.DbPoolSchemaRls.

func (*PgxPostgresPool) Shutdown added in v0.9.3

func (p *PgxPostgresPool) Shutdown() error

Shutdown implements serviceapi.DbPool.

func (*PgxPostgresPool) Transaction added in v0.9.3

func (p *PgxPostgresPool) Transaction(ctx context.Context, fn func(tx serviceapi.DbExecutor) error) error

Transaction implements serviceapi.DbPool.

Jump to

Keyboard shortcuts

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