mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
remove maxIdleTime feature due to be compatible with old Golang version <= v1.14
This commit is contained in:
@ -160,7 +160,6 @@ type DB interface {
|
||||
SetMaxIdleConnCount(n int) // See Core.SetMaxIdleConnCount.
|
||||
SetMaxOpenConnCount(n int) // See Core.SetMaxOpenConnCount.
|
||||
SetMaxConnLifeTime(d time.Duration) // See Core.SetMaxConnLifeTime.
|
||||
SetMaxConnIdleTime(d time.Duration) // See Core.SetMaxConnIdleTime
|
||||
|
||||
// ===========================================================================
|
||||
// Utility methods.
|
||||
@ -523,13 +522,6 @@ func (c *Core) getSqlDb(master bool, schema ...string) (sqlDb *sql.DB, err error
|
||||
} else {
|
||||
sqlDb.SetConnMaxLifetime(defaultMaxConnLifeTime)
|
||||
}
|
||||
if c.config.MaxConnIdleTime > 0 {
|
||||
if c.config.MaxConnIdleTime > time.Second {
|
||||
sqlDb.SetConnMaxIdleTime(c.config.MaxConnIdleTime)
|
||||
} else {
|
||||
sqlDb.SetConnMaxIdleTime(c.config.MaxConnIdleTime * time.Second)
|
||||
}
|
||||
}
|
||||
return sqlDb, nil
|
||||
}, 0)
|
||||
if v != nil && sqlDb == nil {
|
||||
|
||||
@ -42,7 +42,6 @@ type ConfigNode struct {
|
||||
LinkInfo string `json:"link"` // (Optional) Custom link information, when it is used, configuration Host/Port/User/Pass/Name are ignored.
|
||||
MaxIdleConnCount int `json:"maxIdle"` // (Optional) Max idle connection configuration for underlying connection pool.
|
||||
MaxOpenConnCount int `json:"maxOpen"` // (Optional) Max open connection configuration for underlying connection pool.
|
||||
MaxConnIdleTime time.Duration `json:"maxIdleTime"` // (Optional) Max connection TTL configuration for underlying connection pool.
|
||||
MaxConnLifeTime time.Duration `json:"maxLifeTime"` // (Optional) Max amount of time a connection may be idle before being closed.
|
||||
QueryTimeout time.Duration `json:"queryTimeout"` // (Optional) Max query time for per dql.
|
||||
ExecTimeout time.Duration `json:"execTimeout"` // (Optional) Max exec time for dml.
|
||||
@ -168,15 +167,6 @@ func (c *Core) SetMaxOpenConnCount(n int) {
|
||||
c.config.MaxOpenConnCount = n
|
||||
}
|
||||
|
||||
// SetMaxConnIdleTime sets the maximum amount of time a connection may be idle.
|
||||
//
|
||||
// Expired connections may be closed lazily before reuse.
|
||||
//
|
||||
// If d <= 0, connections are not closed due to a connection's idle time.
|
||||
func (c *Core) SetMaxConnIdleTime(d time.Duration) {
|
||||
c.config.MaxConnIdleTime = d
|
||||
}
|
||||
|
||||
// SetMaxConnLifeTime sets the maximum amount of time a connection may be reused.
|
||||
//
|
||||
// Expired connections may be closed lazily before reuse.
|
||||
@ -189,12 +179,11 @@ func (c *Core) SetMaxConnLifeTime(d time.Duration) {
|
||||
// String returns the node as string.
|
||||
func (node *ConfigNode) String() string {
|
||||
return fmt.Sprintf(
|
||||
`%s@%s:%s,%s,%s,%s,%s,%v,%d-%d-%d-%d#%s`,
|
||||
`%s@%s:%s,%s,%s,%s,%s,%v,%d-%d-%d#%s`,
|
||||
node.User, node.Host, node.Port,
|
||||
node.Name, node.Type, node.Role, node.Charset, node.Debug,
|
||||
node.MaxIdleConnCount,
|
||||
node.MaxOpenConnCount,
|
||||
node.MaxConnIdleTime,
|
||||
node.MaxConnLifeTime,
|
||||
node.LinkInfo,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user