// Package mysql... // // Description : 数据定义 // // Author : go_developer@163.com<白茶清欢> // // Date : 2021-03-01 9:27 下午 package mysql import ( "git.zhangdeman.cn/zhangdeman/logger" ) // DBConfig 数据库连接的配置 // // Author : go_developer@163.com<白茶清欢> // // 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"` // 编码 Connection Connection `json:"connection" yaml:"connection"` // 连接数量配置 } // cfgFile 配置文件定义 // // Author : go_developer@163.com<白茶清欢> // // Date : 14:47 2022/6/9 type cfgFile struct { Flag string `json:"flag"` // 数据库标识 Path string `json:"path"` // 配置文件路径 Type string `json:"type"` // 配置文件类型 Config Database `json:"config"` // 解析之后的配置文件 } const ( // FileTypeYml tml FileTypeYml = "yml" // FileTypeYaml yaml FileTypeYaml = "yaml" // FileTypeJson json FileTypeJson = "json" ) // Database 数据库配置 // // Author : go_developer@163.com<白茶清欢> // // Date : 15:19 2022/6/9 type Database struct { Logger *logger.InputLogConfig `json:"logger" yaml:"logger"` // 日志配置 Master *Mysql `json:"master" yaml:"master"` // 主库配置 Slave *Mysql `json:"slave" yaml:"slave"` // 从库配置 } // Mysql ... // // Author : go_developer@163.com<白茶清欢> // // Date : 18:44 2022/5/14 type Mysql struct { Host string `json:"host" yaml:"host"` // 数据库地址 Port int `json:"port" yaml:"port"` // 数据库端口 Username string `json:"username" yaml:"username"` // 用户名 Password string `json:"password" yaml:"password"` // 密码 Database string `json:"database" yaml:"database"` // 数据库 Charset string `json:"charset" yaml:"charset"` // 数据库编码 Connection *Connection `json:"connection" yaml:"connection"` // 连接配置 LogFileName string `json:"log_file_name" yaml:"log_file_name"` // 日志文件名 Timezone string `json:"timezone" yaml:"timezone"` // 时区 } // Connection 连接数配置 // // Author : go_developer@163.com<白茶清欢> // // Date : 15:18 2022/6/9 type Connection struct { MaxOpen int `json:"max_open" yaml:"max_open"` // 最大打开连接数 MaxIdle int `json:"max_idle" yaml:"max_idle"` // 最大的处理连接数 }