优化连接数的配置
This commit is contained in:
parent
fa88e89c97
commit
988ccb1a39
25
define.go
25
define.go
@ -18,14 +18,23 @@ import (
|
||||
//
|
||||
// Date : 9:32 下午 2021/3/1
|
||||
type DBConfig struct {
|
||||
Host string `json:"host" yaml:"host"` // 主机
|
||||
Port int `json:"port" yaml:"port"` // 端口
|
||||
Database string `json:"database" yaml:"database"` // 数据库
|
||||
Username string `json:"username" yaml:"username"` // 账号
|
||||
Password string `json:"password" yaml:"password"` // 密码
|
||||
Charset string `json:"charset" yaml:"charset"` // 编码
|
||||
MaxOpenConnection int `json:"max_open_connection" yaml:"max_open_connection"` // 打开的最大连接数
|
||||
MaxIdleConnection int `json:"max_idle_connection" yaml:"max_idle_connection"` // 最大空闲连接数
|
||||
Host string `json:"host" yaml:"host"` // 主机
|
||||
Port int `json:"port" yaml:"port"` // 端口
|
||||
Database string `json:"database" yaml:"database"` // 数据库
|
||||
Username string `json:"username" yaml:"username"` // 账号
|
||||
Password string `json:"password" yaml:"password"` // 密码
|
||||
Charset string `json:"charset" yaml:"charset"` // 编码
|
||||
Connection Connection `json:"connection" yaml:"connection"` // 连接数量配置
|
||||
}
|
||||
|
||||
// Connection 连接数配置
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 19:05 2022/6/5
|
||||
type Connection struct {
|
||||
MaxOpen int `json:"max_open" yaml:"max_open"` // 打开的最大连接数
|
||||
MaxIdle int `json:"max_idle" yaml:"max_idle"` // 最大空闲连接数
|
||||
}
|
||||
|
||||
// LogConfig 日志配置
|
||||
|
@ -25,14 +25,16 @@ var (
|
||||
// Date : 11:24 2022/5/16
|
||||
func init() {
|
||||
cfg := &DBConfig{
|
||||
Host: "localhost",
|
||||
Port: 3306,
|
||||
Database: "gateway",
|
||||
Username: "root",
|
||||
Password: "zhangdeman",
|
||||
Charset: "utf8mb4",
|
||||
MaxOpenConnection: 100,
|
||||
MaxIdleConnection: 100,
|
||||
Host: "localhost",
|
||||
Port: 3306,
|
||||
Database: "gateway",
|
||||
Username: "root",
|
||||
Password: "zhangdeman",
|
||||
Charset: "utf8mb4",
|
||||
Connection: Connection{
|
||||
MaxOpen: 100,
|
||||
MaxIdle: 100,
|
||||
},
|
||||
}
|
||||
testDBClient, _ = NewDBClient(cfg, cfg, nil, nil, nil)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user