type alias struct { Name string Driver DriverType DriverName string DataSource string MaxIdleConns int MaxOpenConns int ConnMaxLifetime time.Duration StmtCacheSize int DB *DB DbBaser dbBaser TZ *time.Location Engine string }
type DB struct { // Atomic access only. At top of struct to prevent mis-alignment // on 32-bit platforms. Of type time.Duration. waitDuration int64// Total time waited for new connections.
connector driver.Connector // numClosed is an atomic counter which represents a total number of // closed connections. Stmt.openStmt checks it before cleaning closed // connections in Stmt.css. numClosed uint64
mu sync.Mutex // protects following fields freeConn []*driverConn // free connections ordered by returnedAt oldest to newest connRequests map[uint64]chan connRequest nextRequest uint64// Next key to use in connRequests. numOpen int// number of opened and pending open connections // Used to signal the need for new connections // a goroutine running connectionOpener() reads on this chan and // maybeOpenNewConnections sends on the chan (one send per needed connection) // It is closed during db.Close(). The close tells the connectionOpener // goroutine to exit. openerCh chanstruct{} closed bool dep map[finalCloser]depSet lastPut map[*driverConn]string// stacktrace of last conn's put; debug only maxIdleCount int// zero means defaultMaxIdleConns; negative means 0 maxOpen int// <= 0 means unlimited maxLifetime time.Duration // maximum amount of time a connection may be reused maxIdleTime time.Duration // maximum amount of time a connection may be idle before being closed cleanerCh chanstruct{} waitCount int64// Total number of connections waited for. maxIdleClosed int64// Total number of connections closed due to idle count. maxIdleTimeClosed int64// Total number of connections closed due to idle time. maxLifetimeClosed int64// Total number of connections closed due to max connection lifetime limit.
stop func()// stop cancels the connection opener. }