db

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger(conf Config) logger.Interface

func NewDB

func NewDB(dialector gorm.Dialector, conf Config) (*gorm.DB, error)

Types

type Config

type Config struct {
	Source        string `mapstructure:"source" mask:":([^@]+)@"` // root:****@tcp(127.0.0.1:3306)/test
	DryRun        bool   `mapstructure:"dryRun" yaml:"dryRun"`
	SlowThreshold int    `mapstructure:"slowThreshold" yaml:"slowThreshold"`
	MaxLifeTime   int    `mapstructure:"maxLifeTime" yaml:"maxLifeTime"`
	MaxOpenConn   int    `mapstructure:"maxOpenConn" yaml:"maxOpenConn"`
	MaxIdleConn   int    `mapstructure:"maxIdleConn" yaml:"maxIdleConn"`
}

type DBManager

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

多数据源管理

func NewDBManager

func NewDBManager(cfgKV map[string]InstanceConfig) (*DBManager, error)

func (*DBManager) Default

func (m *DBManager) Default() *gorm.DB

func (*DBManager) Get

func (m *DBManager) Get(k string) *gorm.DB

type InstanceConfig

type InstanceConfig struct {
	Driver gorm.Dialector
	Config Config
}

Jump to

Keyboard shortcuts

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