mysql

package
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config *Config) *query.QueryDb

New 新连接

Types

type Config

type Config struct {
	Username     string        //账号 root
	Password     string        //密码
	Host         string        //host localhost
	Port         string        //端口 3306
	Charset      string        //字符编码 utf8mb4
	Database     string        //默认连接数据库
	MaxOpenConns int           //连接池最多同时打开的连接数
	MaxIdleConns int           //连接池里最大空闲连接数。必须要比maxOpenConns小
	MaxLifetime  time.Duration //连接池里面的连接最大存活时长
	MaxIdleTime  time.Duration //连接池里面的连接最大空闲时长
	DriverName   string
	Trace        bool
}

Config 数据库配置

func (*Config) URI

func (config *Config) URI() string

URI 构造数据库连接

type Proxy

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

Proxy 代理

func NewProxy

func NewProxy() *Proxy

NewProxy 代理池

func (*Proxy) Read

func (proxy *Proxy) Read() *query.QueryDb

Read 获取读库

func (*Proxy) SetRead

func (proxy *Proxy) SetRead(query *query.QueryDb)

SetRead 设置读库

func (*Proxy) SetWrite

func (proxy *Proxy) SetWrite(query *query.QueryDb)

SetWrite 设置写库

func (*Proxy) Write

func (proxy *Proxy) Write() *query.QueryDb

Write 获取写库

type ProxyPool

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

ProxyPool 代理池

func NewProxyPool

func NewProxyPool() *ProxyPool

NewProxyPool 代理池

func (*ProxyPool) NameSpace

func (proxypool *ProxyPool) NameSpace(group string) *Proxy

NameSpace 获取分组

func (*ProxyPool) SetNameSpace

func (proxypool *ProxyPool) SetNameSpace(group string, proxy *Proxy)

SetNameSpace 设置组

Jump to

Keyboard shortcuts

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