db

package
v0.0.0-...-132f7fb Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MySQLManager map[string]*MySQLProxy

Functions

func InitMySQLProxys

func InitMySQLProxys(ps []MySQLProxy) (err error)

Types

type MySQLProxy

type MySQLProxy struct {
	ProxyName string `json:"proxy_name"`
	Username  string
	Password  string
	Addr      string
	Database  string

	Session *sql.DB

	// 连接时设置的参数,参考mysql driver 包的 parseDSNParams 进行添加
	ReadTimeoutSec  int `json:"read_timeout_sec"`
	WriteTimeoutSec int `json:"write_timeout_sec"`
	ConnTimeoutSec  int `json:"conn_timeout_sec"`

	// 建立连接后设置的参数
	ConnMaxLifetime int `json:"conn_max_lifetime"` // 设置链接的生命周期
	MaxIdleConns    int `json:"max_idle_conns"`    // 设置闲置链接数
	MaxOpenConns    int `json:"max_open_conns"`    // 设置最大链接数

}

func CreateMySQLProxy

func CreateMySQLProxy(p *MySQLProxy) (proxy *MySQLProxy, err error)

Jump to

Keyboard shortcuts

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