Documentation ¶
Index ¶
- type ConnectionPool
- func (p *ConnectionPool) Acquire() (*DBConn, error)
- func (p *ConnectionPool) Check(conn *DBConn) bool
- func (p *ConnectionPool) Cleaner()
- func (p *ConnectionPool) Close()
- func (p *ConnectionPool) CloseExpiredConnections()
- func (p *ConnectionPool) MaintainMinConnections()
- func (p *ConnectionPool) Open() error
- func (p *ConnectionPool) Release(conn *DBConn)
- type DBConn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionPool ¶
type ConnectionPool struct { // OpenConnection opens a new connection. OpenConnection func() (*DBConn, error) // contains filtered or unexported fields }
ConnectionPool manages a pool of connections.
func New ¶
func New(maxConnections, minConnections int, waitTimeout time.Duration) *ConnectionPool
New creates a new ConnectionPool.
func (*ConnectionPool) Acquire ¶
func (p *ConnectionPool) Acquire() (*DBConn, error)
Acquire retrieves a connection from the pool.
func (*ConnectionPool) Check ¶
func (p *ConnectionPool) Check(conn *DBConn) bool
Check returns true if connection is healthy.
func (*ConnectionPool) Cleaner ¶
func (p *ConnectionPool) Cleaner()
CleanUpClosedConnections closes expired connections and opens new connections to maintain min connections.
func (*ConnectionPool) CloseExpiredConnections ¶
func (p *ConnectionPool) CloseExpiredConnections()
CloseExpiredConnections closes expired connections.
func (*ConnectionPool) MaintainMinConnections ¶
func (p *ConnectionPool) MaintainMinConnections()
MaintainMinConnections opens connections if below min.
func (*ConnectionPool) Open ¶
func (p *ConnectionPool) Open() error
Open initializes the connection pool.
func (*ConnectionPool) Release ¶
func (p *ConnectionPool) Release(conn *DBConn)
Release puts a connection back into the pool.
Click to show internal directories.
Click to hide internal directories.