emysql

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MAX_IDLE_CONNS     = 2
	MAX_OPEN_CONNS     = 4
	CONN_MAX_LiFE_TIME = 300
	CONN_MAX_IDLE_TIME = 300
)

Variables

View Source
var (
	ErrNameInvalid     error = errors.New("name invalid")
	ErrUserNameInvalid error = errors.New("username invalid")
	ErrPassWordInvalid error = errors.New("password invalid")
	ErrMasterInvalid   error = errors.New("master invalid")
	ErrIPInvalid       error = errors.New("IP invalid")
	ErrDBNameInvalid   error = errors.New("DB name invalid")
	ErrDBLoggerNil     error = errors.New("DB logger nil")
)

Functions

func CloseMysql

func CloseMysql() error

func GetClient

func GetClient(dbname string) (*mClient, error)

func NewMysql

func NewMysql(m MConfigInfo, l Logger) (*mClient, error)

NewMysql retuen mClient

func NewMysqlSingle

func NewMysqlSingle(ms []MConfigInfo, l Logger) error

The NewMysqlSingle function provides a way to instantiate mysql through configuration. If using the NewMysqlSingle function, use the GetClient function provided in the package to manipulate the mClient instance.

Types

type Account

type Account struct {
	Ip       string
	Username string
	Password string
}

type Logger

type Logger interface {
	Printf(f string, args ...interface{})
}

type MConfigInfo

type MConfigInfo struct {
	Name            string
	Master          Account
	Slaves          []Account
	Database        string
	Charset         string
	ParseTime       string
	Loc             string
	ReadTimeout     string
	MaxIdleConns    int
	MaxOpenConns    int
	ConnMaxIdleTime int
	ConnMaxLifetime int
	LogMode         bool
}

Jump to

Keyboard shortcuts

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