Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config[T Connectable] struct { // Min number of connections that will be opened during New() function. MinConns int // Max number of opened connections. MaxConns int // IDLE timeout for every connection. IdleTimeout time.Duration // Function for creating new connections. Factory func() (T, error) }
type Connectable ¶
type ConnectionPool ¶
type ConnectionPool[T Connectable] interface { // Returns number of opened connections. Len() int // Retrieves connection from pool if it exists or opens new connection. Connection(ctx context.Context) (T, error) // Returns connection to pool. Put(conn T) error // Closes all connections and pool. Close() error }
func New ¶
func New[T Connectable](cfg *Config[T]) (ConnectionPool[T], error)
Opens new connection pool.
Click to show internal directories.
Click to hide internal directories.