Documentation
¶
Index ¶
- Constants
- func DefaultNewClient(c *ClientConfig, cc *Config, log logger.Interface) (db *gorm.DB, err error)
- type Client
- type ClientConfig
- type Component
- func (c *Component) CliFlags() []cli.Flag
- func (c *Component) Close(_ gsfLogger.Interface, _ gsf.Config) error
- func (c *Component) Init(log gsfLogger.Interface, cfg gsf.Config) error
- func (c *Component) Prefix() string
- func (c *Component) Run(_ gsfLogger.Interface, _ gsf.Config) error
- func (c *Component) SetPrefix(v string) bool
- type Config
- type ConnConfig
- type Logger
- func (l *Logger) Error(_ context.Context, msg string, data ...interface{})
- func (l *Logger) Info(_ context.Context, msg string, data ...interface{})
- func (l *Logger) LogMode(level logger.LogLevel) logger.Interface
- func (l *Logger) SetLogger(log gsfLogger.Interface)
- func (l *Logger) Trace(_ context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l *Logger) Warn(_ context.Context, msg string, data ...interface{})
Constants ¶
View Source
const ( LogFormatLocalTrace = "%s\n\t[spend:%.3fms] [rows:%v] %s" // file, spend, row, sql LogFormatLocalWarn = "(SLOW SQL >= %v) %s\n\t [spend:%.3fms] [rows:%v] %s" // slow_threshold, file, spend, row, sql LogFormatLocalError = "%s\n\t%s\n\t%s" // file, err, sql LogFormatDevTrace = "[file:%s] [spend:%.3fms] [rows:%v] SQL: %s" // file, spend, row, sql LogFormatDevWarn = "[threshold:%v] [file:%s] [spend:%.3fms] [rows:%v] SQL: %s" // slow_threshold, file, spend, row, sql LogFormatDevError = "[file:%s] [err:%s] SQL: %s" // file, err, sql )
Variables ¶
This section is empty.
Functions ¶
func DefaultNewClient ¶ added in v0.1.3
Types ¶
type Client ¶
type Client struct {
Client *gorm.DB
Cfg ClientConfig
CreateClient func(c *ClientConfig, cc *Config, log logger.Interface) (db *gorm.DB, err error)
// contains filtered or unexported fields
}
type ClientConfig ¶
type ClientConfig struct {
Master ConnConfig `json:"master" yaml:"master"`
Slave []ConnConfig `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 Component ¶
type ConnConfig ¶
type ConnConfig 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 (*ConnConfig) GetConnectDSN ¶
func (c *ConnConfig) GetConnectDSN() string
func (*ConnConfig) GetPrintDSN ¶
func (c *ConnConfig) GetPrintDSN() string
func (*ConnConfig) ParserDSN ¶
func (c *ConnConfig) ParserDSN(val string) error
Click to show internal directories.
Click to hide internal directories.