db

package
v0.0.0-...-9dac4f2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: BSD-2-Clause, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(dbConfigs map[string]*Config, log log.Logger, opts ...Option) (pg.DBI, func(), error)

func NewLoggerHook

func NewLoggerHook(logger log.Logger) pg.QueryHook

func NewTracingHook

func NewTracingHook() pg.QueryHook

Types

type Config

type Config struct {
	// 数据库驱动
	Driver string `json:"driver,omitempty"`
	// 数据库连接
	Source                 string `json:"source,omitempty"`
	ConnMaxLifetimeSeconds int64  `json:"conn_max_lifetime_seconds,omitempty"`
	MaxOpenConns           int32  `json:"max_open_conns,omitempty"`
	MinIdleConns           int32  `json:"min_idle_conns,omitempty"`
	MaxRetries             int32  `json:"max_retries,omitempty"`
}

Config 数据库配置

func (*Config) GetConnMaxLifetimeSeconds

func (x *Config) GetConnMaxLifetimeSeconds() int64

func (*Config) GetDriver

func (x *Config) GetDriver() string

func (*Config) GetMaxOpenConns

func (x *Config) GetMaxOpenConns() int32

func (*Config) GetMaxRetries

func (x *Config) GetMaxRetries() int32

func (*Config) GetMinIdleConns

func (x *Config) GetMinIdleConns() int32

func (*Config) GetSource

func (x *Config) GetSource() string

type Option

type Option func(*options)

func WithApplicationName

func WithApplicationName(applicationName string) Option

WithApplicationName 设置applicationName

func WithCollection

func WithCollection(cc func(name string) (*migrations.Collection, error)) Option

WithCollection 设置migrations的collection

func WithCommand

func WithCommand(cs ...string) Option

WithCommand 设置migrations的command

Jump to

Keyboard shortcuts

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