mysql

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultMaxConns     = 100
	DefaultMaxIdleConns = 10
)

Default values for Mysql.

Variables

This section is empty.

Functions

func CloseDB added in v0.0.14

func CloseDB() error

func CloseTheDB added in v0.0.14

func CloseTheDB(conf DBConfig) error

func GetDB added in v0.0.14

func GetDB() *sqlx.DB

func GetTheDB added in v0.0.14

func GetTheDB(conf DBConfig) (*sqlx.DB, error)

Types

type DB

type DB struct {
	//DSN        string
	Conf DBConfig
	// contains filtered or unexported fields
}

func NewDB

func NewDB(conf DBConfig, opts ...DBOption) *DB

func (*DB) ApplyOptions

func (o *DB) ApplyOptions(options ...DBOption) *DB

func (*DB) Close added in v0.0.14

func (d *DB) Close() error

func (*DB) GetDatabase

func (d *DB) GetDatabase() (*sqlx.DB, error)

func (*DB) GetDatabaseUntil

func (d *DB) GetDatabaseUntil(maxWaitInterval time.Duration, failAfter time.Duration) (*sqlx.DB, error)

type DBConfig

type DBConfig struct {
	Address  string
	DataName string
	UserName string
	Password string
}

type DBOption

type DBOption interface {
	// contains filtered or unexported methods
}

A DBOption sets options.

type DBOptionFunc

type DBOptionFunc func(*DB)

DBOptionFunc wraps a function that modifies DB into an implementation of the DBOption interface.

type EmptyDBOption

type EmptyDBOption struct{}

EmptyDBUrlOption does not alter the DBuration. It can be embedded in another structure to build custom options.

This API is EXPERIMENTAL.

type SQLDB added in v0.0.14

type SQLDB atomic.Value

func (*SQLDB) Load added in v0.0.14

func (m *SQLDB) Load() *sqlx.DB

func (*SQLDB) Store added in v0.0.14

func (m *SQLDB) Store(value *sqlx.DB)

Jump to

Keyboard shortcuts

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