postgres

package
v0.0.0-...-68deef1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Postgres

type Postgres interface {
	// Begin acquires a connection from the Pool and starts a transaction. Unlike database/sql, the
	// context only affects the begin command. i.e. there is no auto-rollback on context cancellation.
	// Begin initiates a transaction block without explicitly setting a transaction mode for the block
	// (see BeginTx with TxOptions if transaction mode is required). *pgxpool.Tx is returned, which
	// implements the pgx.Tx interface. Commit or Rollback must be called on the returned transaction
	// to finalize the transaction block.
	Begin(ctx context.Context) (pgx.Tx, error)
	// Query acquires a connection and executes a query that returns pgx.Rows. Arguments should be
	// referenced positionally from the SQL string as $1, $2, etc. See pgx.Rows documentation to
	// close the returned Rows and return the acquired connection to the Pool.
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	// QueryRow acquires a connection and executes a query that is expected to return at most one
	// row (pgx.Row). Errors are deferred until pgx.Row's Scan method is called. If the query selects
	//  no rows, pgx.Row's Scan will return ErrNoRows. Otherwise, pgx.Row's Scan scans the first
	// selected row and discards the rest. The acquired connection is returned to the Pool when
	// pgx.Row's Scan method is called.
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
	// Exec acquires a connection from the Pool and executes the given SQL. SQL can be either a
	// prepared statement name or an SQL string. Arguments should be referenced positionally from
	// the SQL string as $1, $2, etc. The acquired connection is returned to the pool when the Exec
	// function returns.
	Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	// Close closes all connections in the pool and rejects future Acquire calls. Blocks until all
	// connections are returned to pool and closed.
	Close()
}

Postgres driver interface.

func NewPool

func NewPool(cfg *PostgresConfig) (Postgres, error)

Creating a new postgres pool connection.

type PostgresConfig

type PostgresConfig struct {
	URL      string
	MaxConns int32
	MinConns int32
}

Postgres config structure.

func (*PostgresConfig) Configure

func (c *PostgresConfig) Configure(cfg *pgxpool.Config)

Configure postgres driver.

Jump to

Keyboard shortcuts

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