db

package
v0.0.0-...-2198923 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

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

func NewConnection

func NewConnection(opts ...OptionFunc) *Connection

func (*Connection) Connect

func (t *Connection) Connect(dialector func(string) gorm.Dialector) *gorm.DB

connect

func (*Connection) GetDriverName

func (t *Connection) GetDriverName() string

type ConnectionOptions

type ConnectionOptions struct {
	Driver          string              `mapstructure:"driver" json:"driver" yaml:"driver"`                                  //
	Dsn             string              `mapstructure:"dsn" json:"dsn" yaml:"dsn"`                                           //
	ConnMaxIdletime int                 `mapstructure:"conn-max-idletime" json:"conn-max-idletime" yaml:"conn-max-idletime"` //
	ConnMaxLifetime int                 `mapstructure:"conn-max-lifetime" json:"conn-max-lifetime" yaml:"conn-max-lifetime"` //
	MaxIdleConns    int                 `mapstructure:"max-idle-conns" json:"max-idle-conns" yaml:"max-idle-conns"`          // 空闲中的最大连接数
	MaxOpenConns    int                 `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns"`          // 打开到数据库的最大连接数
	LoggerMode      string              `mapstructure:"logger-mode" json:"logger-mode" yaml:"logger-mode"`                   //
	Registers       []dbresolver.Config `mapstructure:"registers" json:"registers" yaml:"registers"`                         //
}

type OptionFunc

type OptionFunc func(*Connection)

func WithConnMaxIdleTime

func WithConnMaxIdleTime(connMaxIdletime int) OptionFunc

func WithConnMaxLifetime

func WithConnMaxLifetime(connMaxLifetime int) OptionFunc

func WithConnectConfig

func WithConnectConfig(conf ConnectionOptions) OptionFunc

func WithDSN

func WithDSN(dsn string) OptionFunc

func WithDriver

func WithDriver(name string) OptionFunc

func WithMaxIdleConns

func WithMaxIdleConns(maxIdleConns int) OptionFunc

func WithMaxOpenConns

func WithMaxOpenConns(maxOpenConns int) OptionFunc

func WithRegisters

func WithRegisters(registers []dbresolver.Config) OptionFunc

Jump to

Keyboard shortcuts

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