zdb

package
v1.4.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ConnModeMaster connMode = iota
	ConnModeSync
	ConnModeAsync
)

Variables

View Source
var ErrNoRows = pgx.ErrNoRows

Functions

func IsEmpty

func IsEmpty(err error) bool

Types

type Balance

type Balance int
const (
	BalanceRoundRobin Balance = iota
	BalanceLeastConn
)

type Conn

type Conn struct {
	*pgxpool.Pool

	Index   int
	Mode    connMode
	Alive   bool
	PingTry int
}

func (Conn) ToString

func (c Conn) ToString() string

type Logger

type Logger interface {
	Printf(format string, v ...any)
}

type Opts

type Opts interface {
	Opts() (sql string, args map[string]any)
}

type Pool

type Pool struct {
	SrvMaster *Conn
	SrvSync   []*Conn
	SrvAsync  []*Conn

	Continues    []string
	ContinuesTry []string
	TryOnError   int
	TryOnSleep   time.Duration
	Balance      Balance
	PingTimout   time.Duration
	PingTry      int
	Debug        bool
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context) *Pool

func NewDefault

func NewDefault() *Pool

func NewMaster added in v1.3.0

func NewMaster(conn string) *Pool

func (*Pool) Any

func (d *Pool) Any(dst any, sql string, args ...any) error

func (*Pool) AnyAsync

func (d *Pool) AnyAsync(dst any, sql string, args ...any) error

func (*Pool) Get

func (d *Pool) Get(dst any, sql string, args ...any) error

func (*Pool) GetAsync

func (d *Pool) GetAsync(dst any, sql string, args ...any) error

func (*Pool) GetAsyncNamed

func (d *Pool) GetAsyncNamed(dst any, sql string, args map[string]any) error

func (*Pool) GetAsyncOpts

func (d *Pool) GetAsyncOpts(dst any, opts Opts) error

func (*Pool) GetNamed

func (d *Pool) GetNamed(dst any, sql string, args map[string]any) error

func (*Pool) GetOpts

func (d *Pool) GetOpts(dst any, opts Opts) error

func (*Pool) IsAlive

func (d *Pool) IsAlive() bool

func (*Pool) NewConn

func (d *Pool) NewConn(mode connMode, pgConnString string) error

func (*Pool) NewConns

func (d *Pool) NewConns(mode connMode, pgConnString ...string) error

func (*Pool) Ping

func (d *Pool) Ping(q *Conn) (err error)

func (*Pool) Select

func (d *Pool) Select(dst any, sql string, args ...any) error

func (*Pool) SelectAsync

func (d *Pool) SelectAsync(dst any, sql string, args ...any) error

func (*Pool) SelectAsyncNamed

func (d *Pool) SelectAsyncNamed(dst any, sql string, args map[string]any) error

func (*Pool) SelectAsyncOpts

func (d *Pool) SelectAsyncOpts(dst any, opts Opts) error

func (*Pool) SelectNamed

func (d *Pool) SelectNamed(dst any, sql string, args map[string]any) error

func (*Pool) SelectOpts

func (d *Pool) SelectOpts(dst any, opts Opts) error

func (*Pool) Start

func (d *Pool) Start()

func (*Pool) Stat

func (d *Pool) Stat(q *Conn) *Stat

func (*Pool) StatMaster

func (d *Pool) StatMaster() *Stat

func (*Pool) StatPool

func (d *Pool) StatPool() []*Stat

func (*Pool) StatPoolTotal

func (d *Pool) StatPoolTotal() *Stat

func (*Pool) Stop

func (d *Pool) Stop()

func (*Pool) WAny

func (d *Pool) WAny(dst any, sql string, args ...any) error

func (*Pool) WExec

func (d *Pool) WExec(sql string, args ...any) error

func (*Pool) WExecNamed

func (d *Pool) WExecNamed(sql string, args map[string]any) error

func (*Pool) WExecOpts

func (d *Pool) WExecOpts(opts Opts) error

func (*Pool) WGet

func (d *Pool) WGet(dst any, sql string, args ...any) error

func (*Pool) WGetNamed

func (d *Pool) WGetNamed(dst any, sql string, args map[string]any) error

func (*Pool) WGetOpts

func (d *Pool) WGetOpts(dst any, opts Opts) error

func (*Pool) WSelect

func (d *Pool) WSelect(dst any, sql string, args ...any) error

func (*Pool) WSelectNamed

func (d *Pool) WSelectNamed(dst any, sql string, args map[string]any) error

func (*Pool) WSelectOpts

func (d *Pool) WSelectOpts(dst any, opts Opts) error

func (*Pool) WithContext

func (d *Pool) WithContext(ctx context.Context) *Pool

func (*Pool) WithDeadline

func (d *Pool) WithDeadline(dur time.Time) *Pool

func (*Pool) WithTimeout

func (d *Pool) WithTimeout(dur time.Duration) *Pool

type Stat

type Stat struct {
	ID   string
	Mode connMode
	Host string
	Port uint16

	AcquireCount            int64
	AcquireDuration         time.Duration
	AcquiredConns           int32
	CanceledAcquireCount    int64
	ConstructingConns       int32
	EmptyAcquireCount       int64
	IdleConns               int32
	MaxConns                int32
	TotalConns              int32
	NewConnsCount           int64
	MaxLifetimeDestroyCount int64
	MaxIdleDestroyCount     int64
}

Jump to

Keyboard shortcuts

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