database

package
v0.0.0-...-224a6a0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	POSTGRES_DSN                                = "postgresql://%s:%s@%s:%d/%s?sslmode=%s"
	CONTEXT_TRANSACTION_KEY internal.ContextKey = "database:tx"
)
View Source
const PGERRCODE_PATTERN = `\(SQLSTATE (.*)\)`

Variables

View Source
var (
	ErrGeneric     = internal.NewError("Database failed")
	ErrBelowMin    = internal.NewError("Database pool size below minimum")
	ErrTransaction = internal.NewError("Database transaction failed")
)
View Source
var (
	ErrNoRows             = internal.NewError("No rows in result set")
	ErrIntegrityViolation = internal.NewError("Integrity constraint violation")
)

Functions

This section is empty.

Types

type Database

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

func New

func New(ctx context.Context, retries int, configuration internal.Configuration, logger core.Logger) (*Database, error)

func (*Database) Close

func (self *Database) Close(ctx context.Context) error

func (*Database) Exec

func (self *Database) Exec(ctx context.Context, sql string, args ...interface{}) (int, error)

func (*Database) Health

func (self *Database) Health(ctx context.Context) error

func (*Database) Query

func (self *Database) Query(ctx context.Context, sql string, args ...interface{}) Scan

func (*Database) Transaction

func (self *Database) Transaction(ctx context.Context, fn func(ctx context.Context) error) error

type PgxLogger

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

func NewPgxLogger

func NewPgxLogger(logger core.Logger) *PgxLogger

func (PgxLogger) Log

func (self PgxLogger) Log(ctx context.Context, level pgx.LogLevel, msg string, data map[string]interface{})

type Scan

type Scan struct {
	Scan func(dest ...interface{}) error
}

Jump to

Keyboard shortcuts

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