pool

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package pool provides access to PostgreSQL connections.

It should be used only by the metadata package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InTransaction

func InTransaction(ctx context.Context, p *pgxpool.Pool, f func(tx pgx.Tx) error) error

InTransaction uses pool p and wraps the given function f in a transaction.

If f returns an error or context is canceled, the transaction is rolled back.

Types

type Pool

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

Pool provides access to PostgreSQL connections.

func New

func New(u string, l *zap.Logger, sp *state.Provider) (*Pool, error)

New creates a new Pool.

func (*Pool) Close

func (p *Pool) Close()

Close closes all connections in the pool.

func (*Pool) Collect

func (p *Pool) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*Pool) Describe

func (p *Pool) Describe(ch chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

func (*Pool) Get

func (p *Pool) Get(username, password string) (*pgxpool.Pool, error)

Get returns a pool of connections to PostgreSQL database for that username/password combination.

func (*Pool) GetAny

func (p *Pool) GetAny() *pgxpool.Pool

GetAny returns a random open pool of connections to PostgreSQL, or nil if none are available.

Jump to

Keyboard shortcuts

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