Documentation
¶
Overview ¶
Package database implements postgres connection.
Index ¶
- func Close(db *gorm.DB)
- func CloseDB()
- func NewGormDB(dsn string, opts ...GormOption) *gorm.DB
- type GormOption
- type MariaDB
- type MariaDBOption
- func ConnAttempts_MYSQL(attempts int) MariaDBOption
- func ConnMaxIdleTime_MYSQL(d time.Duration) MariaDBOption
- func ConnMaxLifetime_MYSQL(d time.Duration) MariaDBOption
- func ConnTimeout_MYSQL(timeout time.Duration) MariaDBOption
- func MaxIdleConns_MYSQL(size int) MariaDBOption
- func MaxOpenConns_MYSQL(size int) MariaDBOption
- type Postgres
- type PostgresOption
- type Redis
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GormOption ¶
func ConnMaxLifetime_PG_Gorm ¶
func ConnMaxLifetime_PG_Gorm(d time.Duration) GormOption
func MaxIdleConns_PG_Gorm ¶
func MaxIdleConns_PG_Gorm(n int) GormOption
func MaxOpenConns_PG_Gorm ¶
func MaxOpenConns_PG_Gorm(n int) GormOption
type MariaDB ¶
func GetMariaDB ¶
func GetMariaDB() *MariaDB
func NewMariaDB ¶
func NewMariaDB(url string, opts ...MariaDBOption) *MariaDB
type MariaDBOption ¶
type MariaDBOption func(*MariaDB)
func ConnAttempts_MYSQL ¶
func ConnAttempts_MYSQL(attempts int) MariaDBOption
ConnAttempts_MYSQL 尝试连接数据库次数
func ConnMaxIdleTime_MYSQL ¶
func ConnMaxIdleTime_MYSQL(d time.Duration) MariaDBOption
ConnMaxIdleTime_MYSQL 一个连接空闲的最大时长
func ConnMaxLifetime_MYSQL ¶
func ConnMaxLifetime_MYSQL(d time.Duration) MariaDBOption
ConnMaxLifetime_MYSQL 一个连接使用的最大时长
func ConnTimeout_MYSQL ¶
func ConnTimeout_MYSQL(timeout time.Duration) MariaDBOption
ConnTimeout_MYSQL 连接数据库超时时间
func MaxIdleConns_MYSQL ¶
func MaxIdleConns_MYSQL(size int) MariaDBOption
MaxIdleConns_MYSQL 最大闲置的连接数
func MaxOpenConns_MYSQL ¶
func MaxOpenConns_MYSQL(size int) MariaDBOption
MaxOpenConns_MYSQL 最大打开的连接数
type Postgres ¶
type Postgres struct {
Builder squirrel.StatementBuilderType
Pool *pgxpool.Pool
// contains filtered or unexported fields
}
Postgres -.
func GetPostgresDB ¶
func GetPostgresDB() *Postgres
func NewPostgresDB ¶
func NewPostgresDB(url string, opts ...PostgresOption) (*Postgres, error)
NewPostgresDB -.
type PostgresOption ¶
type PostgresOption func(*Postgres)
Option -.
func ConnAttempts_Postgres ¶
func ConnAttempts_Postgres(attempts int) PostgresOption
ConnAttempts -.
func ConnTimeout_Postgres ¶
func ConnTimeout_Postgres(timeout time.Duration) PostgresOption
ConnTimeout -.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.