database

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package database defines the interface to the database.

Package database defines the interface to the database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection added in v0.1.0

type Connection interface {
	Begin(ctx context.Context) (pgx.Tx, error)
	Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
}

Connection defines the methods used to access the database. It is also implemented by a mock database connection for testing.

type Pool added in v0.3.0

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

Pool provides a set of connections to the target database.

func New

func New(ctx context.Context, URL string) (*Pool, error)

New creates a new connection to the database. It waits until a connection can be established, or that the context has been cancelled.

func ReadOnly added in v0.3.0

func ReadOnly(ctx context.Context, URL string) (*Pool, error)

ReadOnly creates a new connection to the database with follower reads It waits until a connection can be established, or that the context has been cancelled.

func (*Pool) Begin added in v0.3.0

func (p *Pool) Begin(ctx context.Context) (pgx.Tx, error)

Begin implements Connection.

func (*Pool) BeginTx added in v0.3.0

func (p *Pool) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)

BeginTx implements Connection.

func (*Pool) Exec added in v0.3.0

func (p *Pool) Exec(
	ctx context.Context, sql string, args ...interface{},
) (pgconn.CommandTag, error)

Exec implements Connection.

func (*Pool) Query added in v0.3.0

func (p *Pool) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)

Query implements Connection.

func (*Pool) QueryRow added in v0.3.0

func (p *Pool) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row

QueryRow implements Connection.

func (*Pool) Refresh added in v0.3.0

func (p *Pool) Refresh(ctx context.Context) error

Refresh creates a new pool, and reloads the certificates, if applicable. It is typically called when the process receives a SIGHUP.

func (*Pool) SendBatch added in v0.3.0

func (p *Pool) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults

SendBatch implements Connection.

Jump to

Keyboard shortcuts

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