db

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Recover

func Recover(ctx context.Context, fn func(err error))

func TransactionWrapper

func TransactionWrapper(
	ctx context.Context,
	conn Client,
	wrappedFunc func(ctx context.Context, conn Client) error,
) error

Types

type Client

type Client interface {
	Get(ctx context.Context, dest interface{}, serializer Squirrel) error
	Select(ctx context.Context, dest interface{}, serializer Squirrel) error
	Exec(ctx context.Context, sq Squirrel) (pgconn.CommandTag, error)
	Begin(ctx context.Context) (pgx.Tx, error)
}

func NewClient

func NewClient(ctx context.Context, cfg Config) (Client, error)

type Config

type Config struct {
	Host              string        `json:"host" yaml:"host"`
	Port              uint16        `json:"port" yaml:"port"`
	Database          string        `json:"database" yaml:"database"`
	User              string        `json:"user" yaml:"user"`
	Password          string        `json:"password" yaml:"password"`
	TLSConfig         *tls.Config   `json:"tls_config" yaml:"tls_config"` // nil disables TLS
	ConnectTimeout    time.Duration `json:"connect_timeout" yaml:"connect_timeout"`
	MaxConn           int64         `json:"max_conn" yaml:"max_conn"`
	MinConn           int64         `json:"min_conn" yaml:"min_conn"`
	HealCheckDuration time.Duration `json:"heal_check_duration" yaml:"heal_check_duration"`
}

func (*Config) GetDSN

func (db *Config) GetDSN() string

type Squirrel

type Squirrel interface {
	ToSql() (sql string, args []interface{}, err error)
}

Jump to

Keyboard shortcuts

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