gdbc

package
v0.0.0-...-b97b37b Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DB_CONFIG_USERNAME = "root"
	DB_CONFIG_PASSWORD = ""
	DB_CONFIG_HOST     = "127.0.0.1"
	DB_CONFIG_PORT     = 3306
	DB_CONFIG_CHARSET  = "utf8mb4"
	DB_CONFIG_TIMEOUT  = 10
)
View Source
const (
	MYSQL_POOL_MIN_OPEN       = 1
	MYSQL_POOL_MAX_OPEN       = 1
	MYSQL_POOL_MAX_OPEN_LIMIT = 1000
)

Variables

This section is empty.

Functions

func GetMySQLDB

func GetMySQLDB(mysqlConfig *config.MysqlConfig) (*sql.DB, error)

func GetOrmDB

func GetOrmDB(mysqlConfig *config.MysqlConfig) (*gorm.DB, error)

Types

type MySQLPool

type MySQLPool struct {
	sync.Mutex

	Cfg *dbConfig
	// contains filtered or unexported fields
}

func Open

func Open(
	host string,
	port int64,
	username string,
	password string,
	dbName string,
	charset string,
	autoCommit bool,
	timeout int64,
	minOpen int64,
	maxOpen int64,
) (*MySQLPool, error)

func (*MySQLPool) Close

func (this *MySQLPool) Close()

关闭连接池

func (*MySQLPool) DecrNumOpen

func (this *MySQLPool) DecrNumOpen()

func (*MySQLPool) Get

func (this *MySQLPool) Get() (*sql.DB, error)

获取链接

func (*MySQLPool) IncrNumOpen

func (this *MySQLPool) IncrNumOpen()

func (*MySQLPool) MaxOpen

func (this *MySQLPool) MaxOpen() int64

获取允许最大打开数

func (*MySQLPool) MinOpen

func (this *MySQLPool) MinOpen() int64

获取允许最小打开数

func (*MySQLPool) NumOpen

func (this *MySQLPool) NumOpen() int64

当前已经打开的数量

func (*MySQLPool) Release

func (this *MySQLPool) Release(db *sql.DB) error

归还链接

func (*MySQLPool) SetMaxOpen

func (this *MySQLPool) SetMaxOpen(maxOpen int64) error

设置最大允许的链接数

Jump to

Keyboard shortcuts

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