Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HealthCheck ¶
HealthCheck performs a health check on the database connection.
Types ¶
type Config ¶
type Config struct {
Driver Driver `yaml:"driver"`
Postgres *PostgresConfig `yaml:"postgres"`
MySQL *MySQLConfig `yaml:"mysql"`
SQLite *SQLiteConfig `yaml:"sqlite"`
}
Config selects a driver and holds the configuration for each supported database. Only the block matching Driver is used; the others are ignored.
type Driver ¶ added in v0.3.0
type Driver string
Driver identifies the database engine to connect to.
type MySQLConfig ¶ added in v0.3.0
type MySQLConfig struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
User string `yaml:"user"`
Password string `yaml:"password"`
Name string `yaml:"name"`
Pool PoolConfig `yaml:"pool"`
}
MySQLConfig holds MySQL connection configuration.
func (MySQLConfig) DSN ¶ added in v0.3.0
func (c MySQLConfig) DSN() string
DSN returns the MySQL connection string.
func (MySQLConfig) Validate ¶ added in v0.3.0
func (c MySQLConfig) Validate() error
type PoolConfig ¶ added in v0.3.0
type PoolConfig struct {
MaxIdleConns int `yaml:"maxIdleConns"`
MaxOpenConns int `yaml:"maxOpenConns"`
MaxConnLifetimeSeconds int `yaml:"maxConnLifetimeSeconds"`
}
PoolConfig holds database/sql connection pool settings. Any field left at 0 is skipped so the database/sql default applies.
type PostgresConfig ¶ added in v0.3.0
type PostgresConfig struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
User string `yaml:"user"`
Password string `yaml:"password"`
Name string `yaml:"name"`
SSLMode string `yaml:"sslMode"`
Pool PoolConfig `yaml:"pool"`
}
PostgresConfig holds PostgreSQL connection configuration.
func (PostgresConfig) DSN ¶ added in v0.3.0
func (c PostgresConfig) DSN() string
DSN returns the PostgreSQL connection string.
func (PostgresConfig) Validate ¶ added in v0.3.0
func (c PostgresConfig) Validate() error
type SQLiteConfig ¶ added in v0.3.0
type SQLiteConfig struct {
// Path is the database file path, or ":memory:" for an in-memory database.
Path string `yaml:"path"`
Pool PoolConfig `yaml:"pool"`
}
SQLiteConfig holds SQLite connection configuration.
func (SQLiteConfig) DSN ¶ added in v0.3.0
func (c SQLiteConfig) DSN() string
DSN returns the SQLite connection string.
func (SQLiteConfig) Validate ¶ added in v0.3.0
func (c SQLiteConfig) Validate() error