mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
## Summary - Add `MaxIdleConnTime` configuration field to support Go 1.15+ `sql.DB.SetConnMaxIdleTime()` method - Add `SetMaxIdleConnTime()` method to DB interface and Core implementation - Apply configuration during connection pool initialization - Add unit tests for the new configuration option ## Related Issue Closes #4596 ## Changes | File | Change | |------|--------| | `database/gdb/gdb_core_config.go` | Add `MaxIdleConnTime` field to `ConfigNode`, add `SetMaxIdleConnTime()` method | | `database/gdb/gdb.go` | Add interface method, `dynamicConfig` field, initialization logic | | `database/gdb/gdb_z_core_config_test.go` | Add unit test for `SetMaxIdleConnTime` | | `database/gdb/gdb_z_core_config_external_test.go` | Add `ConfigNode` connection pool settings test | ## Usage **Configuration file:** ```yaml database: default: maxIdleTime: "10s" # Close idle connections after 10 seconds ``` **Code:** ```go db.SetMaxIdleConnTime(10 * time.Second) ``` ## Test Plan - [x] Unit tests pass (`go test -run "Test_Core_SetMaxConnections|Test_ConfigNode_ConnectionPoolSettings"`) - [x] All database drivers compile successfully (mysql, pgsql, sqlite, clickhouse, dm, mssql, oracle, etc.) - [x] No breaking changes - follows Go's default behavior (0 = no idle time limit)