Documentation ¶
Index ¶
- Constants
- type BaseModel
- type Client
- func (c *Client) Close()
- func (c *Client) Connect() bool
- func (c *Client) CreateDatabase() bool
- func (c *Client) GetCustomSession(val interface{}, opts *gorm.Session) *gorm.DB
- func (c *Client) GetPrepareStmtSession(val interface{}) *gorm.DB
- func (c *Client) GetSession(val interface{}) *gorm.DB
- func (c *Client) GetSkipTransactionSession(val interface{}) *gorm.DB
- func (c *Client) HealthCheck() error
- type ClientConf
- type DefaultTimeField
Constants ¶
View Source
const ( ConstMysqlUtf8Charset = "utf8" ConstMysqlUtf8mb4Charset = "utf8mb4" ConstDbConnectTimeoutSec = 10 ConstHealthCheckStopTimeoutSec = 5 ConstSlowQueryTimeThreshold = 2000 // 毫秒 ConstExecBatchDefaultSize = 50 // 一次执行批量任务最大多少 ConstMysqlDefaultDbName = "test_db" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseModel ¶
type BaseModel struct { ID int64 `gorm:"primary_key;column:id" json:"id,omitempty" yaml:"id,omitempty" swaggerignore:"true"` DefaultTimeField }
type Client ¶
func NewMysqlClient ¶
func NewMysqlClient(conf *ClientConf) *Client
func (*Client) Close ¶
func (c *Client) Close()
Close 这里优化了关闭顺序,优先健康监测关闭,要不然关闭出现监测失败 指针表示当前对象地址,没有指针表示数据副本是一个copy
func (*Client) CreateDatabase ¶
func (*Client) GetCustomSession ¶
func (*Client) GetPrepareStmtSession ¶
func (*Client) GetSession ¶
func (*Client) GetSkipTransactionSession ¶
func (*Client) HealthCheck ¶
type ClientConf ¶
type ClientConf struct { Address string `json:"address" yaml:"address"` Port uint16 `json:"port" yaml:"port"` ReadTimeout uint32 `json:"readTimeout,omitempty" yaml:"readTimeout,omitempty"` WriteTimeout uint32 `json:"writeTimeout,omitempty" yaml:"writeTimeout,omitempty"` Username string `json:"username" yaml:"username"` Password string `json:"password" yaml:"password"` DB string `json:"db" yaml:"db"` Charset string `json:"charset" yaml:"charset"` MaxIdle int `json:"maxIdle,omitempty" yaml:"maxIdle,omitempty"` MaxOpen int `json:"maxOpen,omitempty" yaml:"maxOpen,omitempty"` SlowQueryThreshold uint32 `json:"slowQueryThreshold,omitempty" yaml:"slowQueryThreshold,omitempty"` ExecBatchSize uint16 `json:"execBatchSize,omitempty" yaml:"execBatchSize,omitempty"` }
type DefaultTimeField ¶
Click to show internal directories.
Click to hide internal directories.