Documentation ¶
Overview ¶
Package db manages interaction with an underlying database store.
This package is a thin layer around pgx that provides a configuration interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { ConnString string `toml:"connection_string"` MaxConnections int `toml:"max_connections"` }
Config represents configuration details for creating a connection pool.
type ConnPool ¶
type ConnPool struct {
// contains filtered or unexported fields
}
Type ConnPool represents a connection pool.
func New ¶
New creates a new ConnPool using the given Config.
Generally only one ConnPool should be used, shared by the entire application.
func (*ConnPool) Open ¶
Open acquires a connection for the caller.
Remember to Release the DB when you're done with it! Otherwise the connection will not be released back to the pool, and eventually you will run out of available connections.
func (*ConnPool) Release ¶
Release returns the given connection back to the connection pool.
This method should be called, probably in a defer statement, before the end of any function that Opens a connection. If a connection is not released, eventually the application will run out of available connections and fail.