dst

package module
v0.0.0-...-87a3dab Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

README

DST

数据源相关的连接和工具

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chk

func Chk(err error, entries ...*logrus.Entry)

func CleanLoop

func CleanLoop(query *gorm.DB, dest interface{}, batchSize int, hdl Hdl, thresholds ...int) error

依赖于hdl会自动处理掉where命中数据,最终where里不包含命中记录

func ConnectToPG

func ConnectToPG(conn string, opts ...Option) (*gorm.DB, error)

func DockerPg

func DockerPg(version ...string) (string, func())

DockerPg 测试辅助函数。 利用 dockertest 生成一次性pg实例。 version , 可选参数,用于指定pg版本, 默认为 "13" 返回 gorm 连接字符串, 以及用于清理此pg实例的 cleanup 函数

func Dup

func Dup(err error) bool

func Exist

func Exist(db *gorm.DB) (bool, error)

Exist 是否存在

func NewGormLogger

func NewGormLogger() gormlogger.Interface

func NotFound

func NotFound(err error) bool

NotFound 是否没有找到

Types

type Hdl

type Hdl func() error

type Lg

type Lg struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func Log

func Log(entry ...*logrus.Entry) *Lg

func (*Lg) Entry

func (p *Lg) Entry() *logrus.Entry

func (*Lg) WithErr

func (p *Lg) WithErr(err error) *Lg

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option 是一个连接选项 interface.

func WithConnMaxLifetime

func WithConnMaxLifetime(d time.Duration) Option

WithConnMaxLifetime sets the maximum amount of time a connection may be reused.

func WithMaxIdleConns

func WithMaxIdleConns(n int) Option

WithMaxIdleConns sets the maximum number of connections in the idle connection pool.

func WithMaxOpenConns

func WithMaxOpenConns(n int) Option

WithMaxOpenConns sets the maximum number of open connections to the database.

func WithPing

func WithPing(d time.Duration) Option

WithPing send db ping repeatedly, avoid db connection being released

Jump to

Keyboard shortcuts

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