Documentation
¶
Index ¶
- Variables
- type Config
- type Connection
- type Factory
- type Pool
- func (p *Pool) CleanupStale() int
- func (p *Pool) Close() error
- func (p *Pool) Get(ctx context.Context) (Connection, error)
- func (p *Pool) GetMetrics() *metrics.Metrics
- func (p *Pool) Put(conn Connection) error
- func (p *Pool) StartCleaner(interval time.Duration) chan struct{}
- func (p *Pool) Stats() PoolStats
- type PoolStats
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrPoolClosed is returned when pool is closed ErrPoolClosed = errors.New("connection pool is closed") // ErrPoolExhausted is returned when pool has no available connections ErrPoolExhausted = errors.New("connection pool exhausted") // ErrConnectionInvalid is returned when connection is invalid ErrConnectionInvalid = errors.New("connection is invalid") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// MaxIdle is maximum number of idle connections
MaxIdle int
// MaxOpen is maximum number of open connections
MaxOpen int
// MaxLifetime is maximum connection lifetime
MaxLifetime time.Duration
// MaxIdleTime is maximum idle time before closing
MaxIdleTime time.Duration
// WaitTimeout is maximum wait time for connection
WaitTimeout time.Duration
}
Config configures connection pool
type Connection ¶
type Connection interface {
// Close closes the connection
Close() error
// IsValid checks if connection is valid
IsValid() bool
// Reset resets connection state for reuse
Reset() error
}
Connection represents a pooled connection
type Factory ¶
type Factory interface {
// Create creates a new connection
Create() (Connection, error)
// Validate checks if connection is valid
Validate(conn Connection) bool
}
Factory creates new connections
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is a generic connection pool
func (*Pool) CleanupStale ¶
CleanupStale removes stale connections from pool
func (*Pool) Get ¶
func (p *Pool) Get(ctx context.Context) (Connection, error)
Get retrieves a connection from pool
func (*Pool) GetMetrics ¶
GetMetrics returns pool metrics
func (*Pool) StartCleaner ¶
StartCleaner starts background cleaner goroutine
Click to show internal directories.
Click to hide internal directories.