database

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package database implements postgres connection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(db *gorm.DB)

func CloseDB

func CloseDB()

func NewGormDB

func NewGormDB(dsn string, opts ...GormOption) *gorm.DB

NewGormDB "host=localhost user=postgres password=111111 dbname=user port=5432 sslmode=disable TimeZone=Asia/Shanghai"

Types

type GormOption

type GormOption func(*sql.DB)

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

type MariaDB struct {
	*sql.DB
	// contains filtered or unexported fields
}

func GetMariaDB

func GetMariaDB() *MariaDB

func NewMariaDB

func NewMariaDB(url string, opts ...MariaDBOption) *MariaDB

func (*MariaDB) Close

func (db *MariaDB) Close()

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 -.

func (*Postgres) Close

func (p *Postgres) Close()

Close -.

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 -.

func MaxPoolSize_Postgres

func MaxPoolSize_Postgres(size int) PostgresOption

MaxPoolSize -.

type Redis

type Redis struct {
	*redis.Client
	// contains filtered or unexported fields
}

func NewRedisClient

func NewRedisClient(addr, pwd string, db, poolSize int) *Redis

func (*Redis) Close

func (r *Redis) Close()

Directories

Path Synopsis
rabbitmq

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL