From 988ccb1a393eae20f30079635c77005908f29cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sun, 5 Jun 2022 19:07:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BF=9E=E6=8E=A5=E6=95=B0?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- define.go | 25 +++++++++++++++++-------- mysql_test.go | 18 ++++++++++-------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/define.go b/define.go index 611160a..f2eae64 100644 --- a/define.go +++ b/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 日志配置 diff --git a/mysql_test.go b/mysql_test.go index 31d6b5e..4464286 100644 --- a/mysql_test.go +++ b/mysql_test.go @@ -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) }