Documentation
¶
Index ¶
- Constants
- func CreateSSHConn(cnf *SSHConfig) (*ssh.Client, error)
- func Dsn2DB(dsnURL string, withLog bool) (*gorm.DB, error)
- func ForUpdate(db *gorm.DB, lock bool) *gorm.DB
- func IsDupError(err error) bool
- func IsNotFoundErr(err error) bool
- func New(dsn string, opts ...Option) (*gorm.DB, error)
- func NewDBByDsn(dsn *Dsn, opts ...Option) (*gorm.DB, error)
- func NewDBBySSH(sshCnf *SSHConfig, dsn *Dsn, opts ...Option) (*gorm.DB, error)
- func NewGorm(dsn string, maxOpenConn, maxIdle int, maxLifeTime time.Duration, log bool) (*gorm.DB, error)
- func NewUberLogger() logger.Interface
- func ToGRPCDupErr(err error) error
- func ToGRPCNotFoundErr(err error) error
- func Transact(db *gorm.DB, fnList ...GormProcFn) (err error)
- type Dsn
- type GormProcFn
- type Option
- type SSHConfig
- type SSHDialer
Constants ¶
View Source
const ( DefaultMaxOpenCount = 40 DefaultMaxIdleCount = 20 DefaultMaxLifeTime = time.Hour )
Variables ¶
This section is empty.
Functions ¶
func NewDBByDsn ¶ added in v0.9.1
NewDBByDsn : new *gorm.DB by Dsn
func NewDBBySSH ¶ added in v0.9.0
NewDBBySSH new db by ssh
func NewGorm ¶
func NewGorm(dsn string, maxOpenConn, maxIdle int, maxLifeTime time.Duration, log bool) (*gorm.DB, error)
NewGorm 获取一个db客户端 --maxOpenConn 最大打开连接数
func NewUberLogger ¶ added in v1.2.8
NewUberLogger 创建一个新的 GORM 日志适配器
Types ¶
type Dsn ¶
type Dsn struct {
User string `json:"user" toml:"user"`
Password string `json:"password" toml:"password"`
Proto string `json:"proto" toml:"proto"`
Host string `json:"host" toml:"host"`
Schema string `json:"schema" toml:"schema"`
Options map[string]string `json:"options" toml:"options"`
}
func (*Dsn) UseDefault ¶ added in v0.1.8
type GormProcFn ¶
GormProcFn gorm func
func Combine ¶ added in v0.8.5
func Combine(fns ...GormProcFn) GormProcFn
Combine : combine serial GormProcFn to one to avoid append
type Option ¶
type Option func(*_Option)
func WithLogSwitch ¶ added in v0.9.0
func WithLogger ¶ added in v1.2.8
WithLogger : set logger
func WithMaxIdle ¶
func WithMaxLifeTime ¶
func WithMaxOpenConn ¶
Click to show internal directories.
Click to hide internal directories.