dbs

package
v0.0.0-...-849f898 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Transaction

func Transaction(ctx context.Context, db *sql.DB, opt *sql.TxOptions, fn func(tx *sql.Tx) error) error

Transaction ...

Types

type MySqls

type MySqls struct {
	// contains filtered or unexported fields
}

MySqls ...

func MysqlInst

func MysqlInst(mysqlConfs ...MysqlConf) *MySqls

MysqlInst ...

func (*MySqls) DB

func (m *MySqls) DB(key string) (*sql.DB, error)

DB ...

func (*MySqls) DBOrm

func (m *MySqls) DBOrm(key string) (*gorm.DB, error)

DBOrm ...

func (*MySqls) Init

func (m *MySqls) Init(dbs []MysqlConf) error

Init ...

func (*MySqls) Ping

func (m *MySqls) Ping(key string) error

Ping ...

type MysqlConf

type MysqlConf struct {
	Name string        `yaml:"name"`
	Type string        `yaml:"type"`
	Dsn  string        `yaml:"dsn"`
	Exts MysqlConfExts `yaml:"exts"`
}

MysqlConf ...

type MysqlConfExts

type MysqlConfExts struct {
	MaxIdle     int    `yaml:"maxIdle"`
	MaxOpen     int    `yaml:"maxOpen"`
	MaxPoolSize int    `yaml:"maxPoolSize"`
	MaxConnLife string `yaml:"maxConnLifeTime"`
}

MysqlConfExts ...

type RedisConf

type RedisConf struct {
	Name   string        `yaml:"name"`
	Host   string        `yaml:"host"`
	Passwd string        `yaml:"passwd"`
	Db     int           `yaml:"db"`
	Exts   RedisConfExts `yaml:"exts"`
}

RedisConf ...

type RedisConfExts

type RedisConfExts struct {
	MaxIdle      int    `yaml:"maxIdle"`
	MaxActive    int    `yaml:"maxActive"`
	IdleTimeout  string `yaml:"idleTimeout"`
	ConnTimeout  string `yaml:"connTimeout"`
	MaxConnLife  string `yaml:"maxConnLifetime"`
	TestOnBorrow string `yaml:"testOnBorrow"`
}

RedisConfExts ...

type Redises

type Redises struct {
	// contains filtered or unexported fields
}

Redises ...

func RedisInst

func RedisInst(redisConfs ...RedisConf) *Redises

RedisInst 默认使用 useClient = true

func (*Redises) Client

func (r *Redises) Client(key string) *redis.Client

Client get *redis.Client (redis.v5)

func (*Redises) Conn

func (r *Redises) Conn(key string) redigo.Conn

Conn get redis.Conn (redigo)

func (*Redises) Init

func (r *Redises) Init(confs []RedisConf, useClient bool) error

Init ...

func (*Redises) Ping

func (r *Redises) Ping(key string) (string, error)

Ping ...

func (*Redises) PubConn

func (r *Redises) PubConn(key string) redigo.Conn

PubConn ...(redigo)

func (*Redises) SubConn

func (r *Redises) SubConn(key string) redigo.PubSubConn

SubConn ...(redigo)

Jump to

Keyboard shortcuts

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