pg

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned for get ops with no results
	ErrNotFound = trail.NewErrorNotFound("the requested item does not exist")

	// ErrUnique is return for write ops that violate unique constraint
	ErrUnique = trail.NewErrorConflict("an item already exists matching your request")

	// ErrBadValue is returned for encoding errors
	ErrBadValue = trail.NewError("bad value")
)

Functions

This section is empty.

Types

type Option

type Option func(conf *ProviderConfig)

Option A sql db option

func WithConnectTimeout

func WithConnectTimeout(d time.Duration) Option

WithConnectTimeout configure pg with custom connect timeout

func WithMaxConnLifetime

func WithMaxConnLifetime(d time.Duration) Option

WithMaxConnLifetime configure pg with custom max connection lifetime

func WithMaxConns

func WithMaxConns(n int32) Option

WithMaxConns configure pg with custom max connections

type Provider

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

Provider to sql database

func New

func New(dsn string, migrations fs.FS, opts ...Option) (*Provider, error)

New creates a new pg database db

func (Provider) Begin

func (p Provider) Begin(ctx context.Context, opts ...db.TxOption) (db.UnitOfWork, error)

func (Provider) Repository

func (p Provider) Repository() db.Repository

type ProviderConfig

type ProviderConfig struct {
	MaxConns        int32
	MaxConnLifetime time.Duration
	ConnectTimeout  time.Duration
}

ProviderConfig custom options for pg configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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