Documentation
¶
Index ¶
- func BuildDSN(config Config) string
- type Config
- type ConfigOption
- func WithDBName(dbName string) ConfigOption
- func WithHealthCheckPeriod(healthCheckPeriod int) ConfigOption
- func WithHost(host string) ConfigOption
- func WithMaxConnIdleTime(maxConnIdleTime int) ConfigOption
- func WithMaxConnLifetime(maxConnLifetime int) ConfigOption
- func WithMaxConns(maxConns int32) ConfigOption
- func WithMinConns(minConns int32) ConfigOption
- func WithPassword(password string) ConfigOption
- func WithPathOfMigrations(pathOfMigrations string) ConfigOption
- func WithPort(port int) ConfigOption
- func WithSSLMode(sslMode string) ConfigOption
- func WithUsername(username string) ConfigOption
- type Database
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Host string `koanf:"host"`
Port int `koanf:"port"`
Username string `koanf:"user"`
Password string `koanf:"password"`
DBName string `koanf:"db_name"`
Schema string `koanf:"schema"`
SSLMode string `koanf:"ssl_mode"`
MaxConns int32 `koanf:"max_conns"`
MinConns int32 `koanf:"min_conns"`
MaxConnLifetime int `koanf:"max_conn_lifetime"`
MaxConnIdleTime int `koanf:"max_conn_idle_time"`
HealthCheckPeriod int `koanf:"health_check_period"`
PathOfMigrations string `koanf:"path_of_migrations"`
}
Config represents the configuration for a database connection.
func NewConfig ¶
func NewConfig(opts ...ConfigOption) Config
NewConfig creates a new Config with default values and applies the provided options.
type ConfigOption ¶
type ConfigOption func(*Config)
ConfigOption defines a function that modifies a Config.
func WithDBName ¶
func WithDBName(dbName string) ConfigOption
WithDBName sets the DBName field of the Config.
func WithHealthCheckPeriod ¶
func WithHealthCheckPeriod(healthCheckPeriod int) ConfigOption
WithHealthCheckPeriod sets the HealthCheckPeriod field of the Config.
func WithMaxConnIdleTime ¶
func WithMaxConnIdleTime(maxConnIdleTime int) ConfigOption
WithMaxConnIdleTime sets the MaxConnIdleTime field of the Config.
func WithMaxConnLifetime ¶
func WithMaxConnLifetime(maxConnLifetime int) ConfigOption
WithMaxConnLifetime sets the MaxConnLifetime field of the Config.
func WithMaxConns ¶
func WithMaxConns(maxConns int32) ConfigOption
WithMaxConns sets the MaxConns field of the Config.
func WithMinConns ¶
func WithMinConns(minConns int32) ConfigOption
WithMinConns sets the MinConns field of the Config.
func WithPassword ¶
func WithPassword(password string) ConfigOption
WithPassword sets the Password field of the Config.
func WithPathOfMigrations ¶
func WithPathOfMigrations(pathOfMigrations string) ConfigOption
WithPathOfMigrations sets the PathOfMigrations field of the Config.
func WithSSLMode ¶
func WithSSLMode(sslMode string) ConfigOption
WithSSLMode sets the SSLMode field of the Config.
func WithUsername ¶
func WithUsername(username string) ConfigOption
WithUsername sets the Username field of the Config.