Documentation
¶
Overview ¶
Package sqlpool applies connection-pool limits to a database/sql handle. Go's default MaxIdleConns of 2 causes connection churn under bursts.
Index ¶
Constants ¶
View Source
const ( // DefaultConnMaxLifetime recycles connections so they do not pin to a failed-over server. DefaultConnMaxLifetime = 5 * time.Minute // DefaultConnMaxIdleTime returns capacity to the server when the process goes quiet. DefaultConnMaxIdleTime = time.Minute )
Variables ¶
This section is empty.
Functions ¶
func DefaultMaxOpenConns ¶
DefaultMaxOpenConns returns the open-connection limit for a driver name ("mysql" | "postgres" | "sqlite"). Unrecognised names get the MySQL value.
Types ¶
type Config ¶
type Config struct {
// Driver selects the per-driver default for MaxOpenConns: "mysql" |
// "postgres" | "sqlite".
Driver string
// MaxOpenConns caps total connections (in use plus idle); 0 is unlimited.
MaxOpenConns *int
// MaxIdleConns caps retained idle connections; nil mirrors MaxOpenConns,
// 0 keeps none.
MaxIdleConns *int
// ConnMaxLifetimeSeconds recycles a connection after this age; 0 never.
ConnMaxLifetimeSeconds *int
// ConnMaxIdleTimeSeconds closes a connection idle this long; 0 never.
ConnMaxIdleTimeSeconds *int
}
Config carries pool limits. nil takes the default; 0 lifts the limit.
Click to show internal directories.
Click to hide internal directories.