Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var PostgreDefaultConfigs = make(PostgreConfigs_T, 1)
Functions ¶
func Connect ¶
func Connect(config PostgreConfig_T) error
func Init ¶
func Init(cfgs PostgreConfigs_T) error
func LoadDefaultConfig ¶
func LoadDefaultConfig() error
Types ¶
type PostgreConfig_T ¶
type PostgreConfig_T struct {
Tag string `json:"tag"`
// timeout=5s 连接超时时间
// readTimeout=10s 读取超时
// writeTimeout=10s 写入超时
// charset=utf8mb4 字符集(支持emoji)
// loc=Local 使用本地时区
// interpolateParams=true 预处理语句优化(可能提升性能)
// "username:password@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&timeout=10s&readTimeout=30s&writeTimeout=30s&parseTime=true&loc=Local"
Addr string `json:"addr"`
MaxOpenConns int `json:"maxOpenConns"` // 设置最大打开连接数
MaxIdleConns int `json:"maxIdleConns"` // 设置最大空闲连接数
ConnMaxLifetime time.Duration `json:"-"` // 设置连接的最大生命周期 单位s
ConnMaxLifetimeInt int `json:"connMaxLifetimeInt"` // 设置连接的最大存活时间 单位s
}
type PostgreConfigs_T ¶
type PostgreConfigs_T map[string]PostgreConfig_T
Click to show internal directories.
Click to hide internal directories.