Documentation
¶
Index ¶
Constants ¶
View Source
const Default = "default"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DBConfig ¶
type DBConfig struct {
Name string `json:"name" yaml:"name"`
Driver string `json:"driver" yaml:"driver"`
// DSN data source name
//
// [MySQL] username:password@tcp(localhost:3306)/dbname?timeout=10s&charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&loc=Local
//
// [Postgres] host=localhost port=5432 user=root password=secret dbname=test connect_timeout=10 sslmode=disable
//
// [SQLite] file::memory:?cache=shared
DSN string `json:"dsn" yaml:"dsn"`
// Options optional settings to setup db connection.
Options *DBOptions `json:"options" yaml:"options"`
}
DBConfig keeps the settings to setup db connection.
type DBOptions ¶
type DBOptions struct {
// MaxOpenConns is the maximum number of open connections to the database.
// Use value -1 for no timeout and 0 for default.
// Default is 20.
MaxOpenConns int `json:"max_open_conns" yaml:"maxOpenConns"`
// MaxIdleConns is the maximum number of connections in the idle connection pool.
// Use value -1 for no timeout and 0 for default.
// Default is 10.
MaxIdleConns int `json:"max_idle_conns" yaml:"maxIdleConns"`
// ConnMaxLifetime is the maximum amount of time a connection may be reused.
// Use value -1 for no timeout and 0 for default.
// Default is 10 minutes.
ConnMaxLifetime time.Duration `json:"conn_max_lifetime" yaml:"connMaxLifetime"`
// ConnMaxIdleTime is the maximum amount of time a connection may be idle.
// Use value -1 for no timeout and 0 for default.
// Default is 5 minutes.
ConnMaxIdleTime time.Duration `json:"conn_max_idle_time" yaml:"connMaxIdleTime"`
}
DBOptions optional settings to setup db connection.
Click to show internal directories.
Click to hide internal directories.