component

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: MulanPSL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MysqlCreateClient = mysqlDefaultNewClient

Functions

This section is empty.

Types

type MysqlClient

type MysqlClient struct {
	Client *gorm.DB
	Cfg    MysqlClientConfig
	// contains filtered or unexported fields
}

func (*MysqlClient) CliFlags

func (c *MysqlClient) CliFlags(name string) []cli.Flag

func (*MysqlClient) Load

func (c *MysqlClient) Load(r *MysqlComponent, name string, cfg *MysqlConfig, log logger.Interface) (err error)

func (*MysqlClient) Ref

func (c *MysqlClient) Ref() *MysqlComponent

type MysqlClientConfig

type MysqlClientConfig struct {
	Master     MysqlConnConfig   `json:"master"        yaml:"master"`
	Slave      []MysqlConnConfig `json:"slave"         yaml:"slave"`
	MaxOpenNum int               `json:"max_open_num"  yaml:"max_open_num"`
	MaxIdleNum int               `json:"max_idle_num"  yaml:"max_idle_num"`
}

type MysqlComponent

type MysqlComponent struct {
	DSNPrint bool
	Cfg      MysqlConfig
	Clts     map[string]*MysqlClient
	Log      MysqlLogger
}

func (*MysqlComponent) CliFlags

func (c *MysqlComponent) CliFlags() []cli.Flag

func (*MysqlComponent) Close

func (c *MysqlComponent) Close(_ int, _ bool, _, _, _ func(string, ...interface{})) error

func (*MysqlComponent) Init

func (c *MysqlComponent) Init(env int, logMore bool, ctx *cli.Context, infoLog, warnLog, errLog func(string, ...interface{})) error

func (*MysqlComponent) LoadOne

func (c *MysqlComponent) LoadOne(name string) (err error)

func (*MysqlComponent) Run

func (c *MysqlComponent) Run(_ int, _ bool, _, _, _ func(string, ...interface{})) error

type MysqlConfig

type MysqlConfig struct {
	MaxLifeTime   int `json:"max_req_time"    yaml:"max_req_time"`
	MaxIdleTime   int `json:"max_idle_time"   yaml:"max_idle_time"`
	SlowThreshold int `json:"slow_threshold"  yaml:"slow_threshold"`
}

type MysqlConnConfig

type MysqlConnConfig struct {
	Host     string `json:"host"      yaml:"host"`
	UserName string `json:"user"      yaml:"user"`
	Password string `json:"password"  yaml:"password"`
	Database string `json:"db"        yaml:"db"`
	Options  string `json:"options"   yaml:"options"`
	// contains filtered or unexported fields
}

func (*MysqlConnConfig) GetConnectDSN

func (c *MysqlConnConfig) GetConnectDSN() string

func (*MysqlConnConfig) GetPrintDSN

func (c *MysqlConnConfig) GetPrintDSN() string

func (*MysqlConnConfig) ParserDSN

func (c *MysqlConnConfig) ParserDSN(val string) error

type MysqlLogger

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

func (*MysqlLogger) Error

func (l *MysqlLogger) Error(ctx context.Context, msg string, data ...interface{})

func (*MysqlLogger) Info

func (l *MysqlLogger) Info(ctx context.Context, msg string, data ...interface{})

func (*MysqlLogger) LogMode

func (l *MysqlLogger) LogMode(level logger.LogLevel) logger.Interface

func (*MysqlLogger) SetLogger

func (l *MysqlLogger) SetLogger(info, warn, error func(string, ...interface{}))

func (*MysqlLogger) Trace

func (l *MysqlLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

func (*MysqlLogger) Warn

func (l *MysqlLogger) Warn(ctx context.Context, msg string, data ...interface{})

Jump to

Keyboard shortcuts

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