gormPool

package
v0.0.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Common added in v0.0.3

type Common struct {
	Driver string `yaml:"driver"`
}

type DbSetting added in v0.0.3

type DbSetting struct {
	Common *Common       `yaml:"common"`
	MySql  *MySqlSetting `yaml:"mysql"`
}

func NewDbSetting added in v0.0.3

func NewDbSetting(path string) *DbSetting

NewDbSetting 初始化

type Dsn

type Dsn struct {
	Name    string
	Content string
}

type MySqlConnection

type MySqlConnection struct {
	Username  string `yaml:"username"`
	Password  string `yaml:"password"`
	Host      string `yaml:"host"`
	Port      uint16 `yaml:"port"`
	Database  string `yaml:"database"`
	Charset   string `yaml:"charset"`
	Collation string `yaml:"collation"`
}

type MySqlPool

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

func NewMySqlPool

func NewMySqlPool(dbSetting *DbSetting) *MySqlPool

NewMySqlPool 创建mysql链接池对象

func (*MySqlPool) Close added in v0.0.2

func (receiver *MySqlPool) Close() error

Close 关闭数据库链接

func (*MySqlPool) GetConn added in v0.0.6

func (receiver *MySqlPool) GetConn() *gorm.DB

GetMain 获取主数据库链接

func (*MySqlPool) GetRws added in v0.0.2

func (receiver *MySqlPool) GetRws() *gorm.DB

GetRws 获取带有读写分离的数据库链接

type MySqlSetting added in v0.0.2

type MySqlSetting struct {
	MaxOpenConns int                         `yaml:"maxOpenConns"`
	MaxIdleConns int                         `yaml:"maxIdleConns"`
	MaxLifetime  int                         `yaml:"maxLifetime"`
	MaxIdleTime  int                         `yaml:"maxIdleTime"`
	Rws          bool                        `yaml:"rws"`
	Main         *MySqlConnection            `yaml:"main"`
	Sources      map[string]*MySqlConnection `yaml:"sources"`
	Replicas     map[string]*MySqlConnection `yaml:"replicas"`
}

Jump to

Keyboard shortcuts

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