Documentation ¶
Index ¶
- Constants
- Variables
- type AuthRow
- type ClientConn
- type Conner
- type DBStats
- type Pool
- func (p *Pool) AcquireConn() (*ServerConn, error)
- func (p *Pool) Close() error
- func (p *Pool) Collector(destHost, destDB string) *poolCollector
- func (p *Pool) ReleaseConn(sc *ServerConn)
- func (p *Pool) Reload(new PoolConfig)
- func (p *Pool) SetConnMaxIdleTime(d time.Duration)
- func (p *Pool) SetConnMaxLifetime(d time.Duration)
- func (p *Pool) SetMaxIdleConns(n int)
- func (p *Pool) SetMaxOpenConns(n int)
- func (p *Pool) Stats() DBStats
- type PoolConfig
- type PoolManager
- type Server
- type ServerConn
Constants ¶
const ( StatusUnset byte = 0 StatusIdle byte = 'I' StatusInTx byte = 'T' StatusError byte = 'E' )
Variables ¶
var ( ErrPoolClosed = errors.New("pool is closed") ErrConnExpired = errors.New("connection expired") )
var ( CommitHash string BuildVersion string BuildDate string GoVersion string )
Version information, assigned by ldflags
var ErrCancelComplete = errors.New("cancel complete")
ErrCancelComplete is a special error to indicate the caller not to log any error messages, since on cancelRequest, the server just closes the connection.
Functions ¶
This section is empty.
Types ¶
type ClientConn ¶
type ClientConn struct {
// contains filtered or unexported fields
}
func NewClientConn ¶
func NewClientConn(handle *pgproto3.Backend, logger *logr.Logger, pool *Pool, schema string) *ClientConn
func (*ClientConn) CancelServerConn ¶
func (cc *ClientConn) CancelServerConn() error
type DBStats ¶
type DBStats struct { MaxOpenConnections int // Maximum number of open connections to the database. // Pool Status OpenConnections int // The number of established connections both in use and idle. InUse int // The number of connections currently in use. Idle int // The number of idle connections. // Counters WaitCount int64 // The total number of connections waited for. WaitDuration time.Duration // The total time blocked waiting for a new connection. MaxIdleClosed int64 // The total number of connections closed due to SetMaxIdleConns. MaxIdleTimeClosed int64 // The total number of connections closed due to SetConnMaxIdleTime. MaxLifetimeClosed int64 // The total number of connections closed due to SetConnMaxLifetime. }
DBStats contains database statistics.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is a copied implementation of just the connection pooling logic from database/sql.
func NewPool ¶
func NewPool(cfg PoolConfig) (*Pool, error)
func (*Pool) AcquireConn ¶
func (p *Pool) AcquireConn() (*ServerConn, error)
func (*Pool) ReleaseConn ¶
func (p *Pool) ReleaseConn(sc *ServerConn)
putConn adds a connection to the db's free pool.
func (*Pool) Reload ¶
func (p *Pool) Reload(new PoolConfig)
func (*Pool) SetConnMaxIdleTime ¶
SetConnMaxIdleTime 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 (*Pool) SetConnMaxLifetime ¶
SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
Expired connections may be closed lazily before reuse.
If d <= 0, connections are not closed due to a connection's age.
func (*Pool) SetMaxIdleConns ¶
SetMaxIdleConns sets the maximum number of connections in the idle connection pool.
If MaxOpenConns is greater than 0 but less than the new MaxIdleConns, then the new MaxIdleConns will be reduced to match the MaxOpenConns limit.
If n <= 0, no idle connections are retained.
The default max idle connections is currently 2. This may change in a future release.
func (*Pool) SetMaxOpenConns ¶
SetMaxOpenConns sets the maximum number of open connections to the database.
If MaxIdleConns is greater than 0 and the new MaxOpenConns is less than MaxIdleConns, then MaxIdleConns will be reduced to match the new MaxOpenConns limit.
If n <= 0, then there is no limit on the number of open connections. The default is 0 (unlimited).
type PoolConfig ¶
type PoolManager ¶
type PoolManager struct {
// contains filtered or unexported fields
}
func NewPoolManager ¶
func NewPoolManager(cfg config.Config, logger *logr.Logger, metrics *metrics) (*PoolManager, error)
func (*PoolManager) GetOrCreatePool ¶
func (pm *PoolManager) GetOrCreatePool(row AuthRow) (pool *Pool, err error)
func (*PoolManager) Reload ¶
func (pm *PoolManager) Reload(cfg config.Config)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server contains all the necessary information to run Perseus
func (*Server) AcceptConns ¶
type ServerConn ¶
func (*ServerConn) CancelRequest ¶
func (sc *ServerConn) CancelRequest(ctx context.Context) error
func (*ServerConn) CheckConn ¶
func (sc *ServerConn) CheckConn() error
func (*ServerConn) Close ¶
func (sc *ServerConn) Close() error
func (*ServerConn) Conn ¶
func (sc *ServerConn) Conn() net.Conn
func (*ServerConn) Exec ¶
func (sc *ServerConn) Exec(sql string) error