代码拉取完成,页面将自动刷新
package gormPool
import (
"gitee.com/jericho-yu/util/v2/honestMan"
)
type (
DbSetting struct {
Common *Common `yaml:"common,omitempty"`
MySql *MySqlSetting `yaml:"mysql,omitempty"`
Postgres *PostgresSetting `yaml:"postgres,omitempty"`
SqlServer *SqlServerSetting `yaml:"sqlServer,omitempty"`
CbitSql *CbitSqlSetting `yaml:"cbitSql,omitempty"`
}
Common struct {
Driver string `yaml:"driver"`
MaxOpenConnections int `yaml:"maxOpenConns"`
MaxIdleConnections int `yaml:"maxIdleConns"`
MaxLifetime int `yaml:"maxLifetime"`
MaxIdleTime int `yaml:"maxIdleTime"`
}
Dsn struct {
Name string
Content string
}
MySqlSetting struct {
Database string `yaml:"database"`
Charset string `yaml:"charset"`
Collation string `yaml:"collation"`
Rws bool `yaml:"rws"`
Main *MySqlConnection `yaml:"main"`
Sources map[string]*MySqlConnection `yaml:"sources"`
Replicas map[string]*MySqlConnection `yaml:"replicas"`
}
MySqlConnection struct {
Username string `yaml:"username"`
Password string `yaml:"password"`
Host string `yaml:"host"`
Port uint16 `yaml:"port"`
}
CbitSqlSetting struct {
Database string `yaml:"database"`
Rws bool `yaml:"rws"`
Main *MySqlConnection `yaml:"main"`
Sources map[string]*CbitSqlConnection `yaml:"sources"`
Replicas map[string]*CbitSqlConnection `yaml:"replicas"`
}
CbitSqlConnection struct {
Username string `yaml:"username"`
Password string `yaml:"password"`
Host string `yaml:"host"`
Port uint16 `yaml:"port"`
}
PostgresSetting struct {
Main *PostgresConnection `yaml:"main"`
}
PostgresConnection struct {
Username string `yaml:"username"`
Password string `yaml:"password"`
Host string `yaml:"host"`
Port uint16 `yaml:"port"`
Database string `yaml:"database"`
TimeZone string `yaml:"timezone"`
SslMode string `yaml:"sslmode"`
}
SqlServerSetting struct {
Main *SqlServerConnection `yaml:"main"`
}
SqlServerConnection struct {
Username string `yaml:"username"`
Password string `yaml:"password"`
Host string `yaml:"host"`
Port uint16 `yaml:"port"`
Database string `yaml:"database"`
}
)
var DbSet DbSetting
// New 初始化:数据库配置
func (DbSetting) New(path string) *DbSetting {
var dbSetting *DbSetting = &DbSetting{}
err := honestMan.App.New(path).LoadYaml(dbSetting)
if err != nil {
return nil
}
return dbSetting
}
func (DbSetting) ExampleYaml() string {
return `common:
driver: "mysql"
maxOpenConns: 100
maxIdleConns: 20
maxLifetime: 100
maxIdleTime: 10
cbitSql:
database: "cbit_db"
rws: false
main:
username: "yjz"
password: "123123"
host: 127.0.0.1
port: 12344
sources:
replicas:
mysql:
database: "tbl_test"
charset: "utf8mb4"
collation: "utf8mb4_general_ci"
rws: true
main:
username: "root"
password: "root"
host: 127.0.0.1
port: 3308
sources:
conn1:
username: "root"
password: "root"
host: 127.0.0.1
port: 3308
conn2:
username: "root"
password: "root"
host: 127.0.0.1
port: 3308
replicas:
conn3:
username: "root"
password: "root"
host: 127.0.0.1
port: 3308
conn4:
username: "root"
password: "root"
host: 127.0.0.1
port: 3308
conn5:
username: "root"
password: "root"
host: 127.0.0.1
port: 3308
postgres:
main:
username: "postgres"
password: "postgres"
host: 127.0.0.1
port: 5432
database: "tbl_test"
sslmode: "disable"
timezone: "Asia/Shanghai"
sqlServer:
maxOpenConns: 100
maxIdleConns: 20
maxLifetime: 100
maxIdleTime: 10
main:
username: "admin"
password: "Admin@1234"
host: 127.0.0.1
port: 9930
database: "tbl_test"`
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。