Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostgresConfig ¶
type PostgresConfig struct { Hostname string Port string Username string Password string DatabaseName string }
PostgresConfig contains the Postgres database configuration arguments
func (*PostgresConfig) Name ¶
func (c *PostgresConfig) Name() string
Name is used by the settings library to replace the default naming convention.
type PostgresConfigComponent ¶
type PostgresConfigComponent struct{}
PostgresConfigComponent satisfies the settings library Component API, and may be used by the settings.NewComponent function.
func (*PostgresConfigComponent) New ¶
func (*PostgresConfigComponent) New(ctx context.Context, c *PostgresConfig) (*PostgresDB, error)
New constructs a DB from a config
func (*PostgresConfigComponent) Settings ¶
func (*PostgresConfigComponent) Settings() *PostgresConfig
Settings populates a set of defaults if none are provided via config.
type PostgresDB ¶
type PostgresDB struct {
// contains filtered or unexported fields
}
PostgresDB is a SQLDB implementation that uses a PostgreSQL database connection pool.
func (*PostgresDB) Conn ¶
func (db *PostgresDB) Conn() *sql.DB
Conn returns the currently initialized and open DB connection if one exists, or nil
func (*PostgresDB) Init ¶
func (db *PostgresDB) Init(ctx context.Context, host, port, username, password, dbname string) error
Init initializes a connection to a Postgres database according to the environment variables POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DATABASE