|
|
@ -38,14 +38,15 @@ func Init(username, password, protocol, address, database string) error {
|
|
|
|
return fmt.Errorf("failed to open database connection: %s", err)
|
|
|
|
return fmt.Errorf("failed to open database connection: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if protocol == "unix" {
|
|
|
|
conns := 1024
|
|
|
|
handle.SetMaxOpenConns(1000)
|
|
|
|
if protocol != "unix" {
|
|
|
|
} else {
|
|
|
|
conns = 256
|
|
|
|
handle.SetMaxOpenConns(200)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handle.SetConnMaxIdleTime(time.Second * 30)
|
|
|
|
handle.SetMaxOpenConns(conns)
|
|
|
|
handle.SetConnMaxLifetime(time.Minute)
|
|
|
|
handle.SetMaxIdleConns(conns/4)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handle.SetConnMaxIdleTime(time.Second * 10)
|
|
|
|
|
|
|
|
|
|
|
|
tx, err := handle.Begin()
|
|
|
|
tx, err := handle.Begin()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|