mysql

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MySQL   DBDriver       = "mysql"
	Source  DBResolverType = "source"
	Replica DBResolverType = "replica"
)

Variables

View Source
var ErrUnsupportedDriver = errors.New("unsupported database driver")
View Source
var ErrUnsupportedResolverType = errors.New("unsupported resolver type")

Functions

func New

func New(ctx context.Context, c DB) (gdb *gorm.DB, err error)

func NewDialect

func NewDialect(driver DBDriver, conn gorm.ConnPool) (gorm.Dialector, error)

func NewGenTool

func NewGenTool(ctx context.Context, cfg DB, tables, outPath, pkgName string)

func NewMysql

func NewMysql(ctx context.Context, c DB) *gorm.DB

Types

type BinlogEvent

type BinlogEvent struct {
}

type DB

type DB struct {
	Driver          DBDriver       `json:"driver" yaml:"driver"`
	Type            DBResolverType `json:"-" yaml:"-"`
	Addr            string         `json:"addr" yaml:"addr"`
	Database        string         `json:"database" yaml:"database"`
	Username        string         `json:"username" yaml:"username"`
	Password        string         `json:"password" yaml:"password"`
	Options         string         `json:"options" yaml:"options"`
	MaxDialTimeout  time.Duration  `json:"maxDialTimeout" yaml:"maxDialTimeout"`
	MaxIdleConn     int            `json:"maxIdleConn" yaml:"maxIdleConn"`
	MaxOpenConn     int            `json:"maxOpenConn" yaml:"maxOpenConn"`
	ConnMaxIdleTime time.Duration  `json:"connMaxIdleTime" yaml:"connMaxIdleTime"`
	ConnMaxLifeTime time.Duration  `json:"connMaxLifeTime" yaml:"connMaxLifeTime"`
	LogInfo         bool           `json:"logInfo" yaml:"logInfo"`
	Resolvers       []*DBResolver  `json:"resolvers" yaml:"resolvers"`
}

DB 数据库配置结构体

func (DB) Equals

func (db DB) Equals(other DB) bool

func (DB) NotEquals

func (db DB) NotEquals(other DB) bool

type DBConn

type DBConn struct {
	Driver          DBDriver      `json:"driver" yaml:"driver"`
	Addr            string        `json:"addr" yaml:"addr"`
	Database        string        `json:"database" yaml:"database"`
	Username        string        `json:"username" yaml:"username"`
	Password        string        `json:"password" yaml:"password"`
	Options         string        `json:"options" yaml:"options"`
	MaxDialTimeout  time.Duration `json:"maxDialTimeout" yaml:"maxDialTimeout"`
	MaxIdleConn     int           `json:"maxIdleConn" yaml:"maxIdleConn"`
	MaxOpenConn     int           `json:"maxOpenConn" yaml:"maxOpenConn"`
	ConnMaxIdleTime time.Duration `json:"connMaxIdleTime" yaml:"connMaxIdleTime"`
	ConnMaxLifeTime time.Duration `json:"connMaxLifeTime" yaml:"connMaxLifeTime"`
}

DBConn 数据库连接配置结构体

type DBConnPool

type DBConnPool struct {
	MaxIdleConn     int           `json:"maxIdleConn" yaml:"maxIdleConn"`
	MaxOpenConn     int           `json:"maxOpenConn" yaml:"maxOpenConn"`
	ConnMaxIdleTime time.Duration `json:"connMaxIdleTime" yaml:"connMaxIdleTime"`
	ConnMaxLifeTime time.Duration `json:"connMaxLifeTime" yaml:"connMaxLifeTime"`
}

DBConnPool 数据库连接池配置

type DBDriver

type DBDriver string

func (DBDriver) IsSupported

func (d DBDriver) IsSupported() bool

IsSupported 检查是否支持的驱动

func (DBDriver) ToString

func (d DBDriver) ToString() string

ToString String 转换为字符串

type DBResolver

type DBResolver struct {
	Driver          DBDriver       `json:"-" yaml:"-"`
	Type            DBResolverType `json:"type" yaml:"type"`
	Addr            string         `json:"addr" yaml:"addr"`
	Database        string         `json:"database" yaml:"database"`
	Username        string         `json:"username" yaml:"username"`
	Password        string         `json:"password" yaml:"password"`
	Options         string         `json:"options" yaml:"options"`
	MaxIdleConn     int            `json:"maxIdleConn" yaml:"maxIdleConn"`
	MaxOpenConn     int            `json:"maxOpenConn" yaml:"maxOpenConn"`
	ConnMaxIdleTime time.Duration  `json:"connMaxIdleTime" yaml:"connMaxIdleTime"`
	ConnMaxLifeTime time.Duration  `json:"connMaxLifeTime" yaml:"connMaxLifeTime"`
}

DBResolver 数据库主从配置

type DBResolverType

type DBResolverType string

func (DBResolverType) ToString

func (r DBResolverType) ToString() string

type DTS

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

func NewDts

func NewDts(c DB) *DTS

func (*DTS) Run

func (d *DTS) Run()

type DbDsn

type DbDsn struct {
	Driver   DBDriver `json:"driver" yaml:"driver"`
	Addr     string   `json:"addr" yaml:"addr"`
	Database string   `json:"database" yaml:"database"`
	Username string   `json:"username" yaml:"username"`
	Password string   `json:"password" yaml:"password"`
	Options  string   `json:"options" yaml:"options"`
}

DbDsn 数据库DBS配置

Jump to

Keyboard shortcuts

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