Documentation ¶
Index ¶
Constants ¶
View Source
const ( ConstMysqlUtf8Charset = "utf8" ConstMysqlUtf8mb4Charset = "utf8mb4" ConstDatabaseReadTimeout = 10000 ConstDatabaseWriteTimeout = 10000 ConstHealthCheckInterval = 5000 ConstProbeContextTimeout = 5000 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:"primaryKey" json:"id" yaml:"id" swaggerignore:"true"` BaseTimeField }
type BaseModelWithSoftDelete ¶
type BaseModelWithSoftDelete struct { ID int64 `gorm:"primaryKey" json:"id" yaml:"id" swaggerignore:"true"` BaseTimeFieldWithSoftDelete }
type BaseTimeField ¶
type BaseTimeFieldWithSoftDelete ¶
type BaseTimeFieldWithSoftDelete struct { BaseTimeField DeleteAt gorm.DeletedAt `json:"-" yaml:"-" swaggerignore:"true"` IsDeleted soft_delete.DeletedAt `json:"-" yaml:"-" gorm:"softDelete:flag" swaggerignore:"true"` }
type Config ¶
type Config 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"` // 最大空闲连接数,如果设置为0,则将禁用连接池,即每次访问都会打开新的连接。 MaxOpen int `json:"maxOpen,omitempty" yaml:"maxOpen,omitempty"` // 最大打开连接数 SlowQueryThreshold uint32 `json:"slowQueryThreshold,omitempty" yaml:"slowQueryThreshold,omitempty"` // 慢查询阈值,单位为毫秒。如果查询的执行时间超过该值,则被视为慢查询。 ExecBatchSize uint16 `json:"execBatchSize,omitempty" yaml:"execBatchSize,omitempty"` // 批处理执行的大小,表示在每个SQL语句中可以提交的最大参数数量。 Logger *zap.SugaredLogger `json:"-" yaml:"-"` }
type FeatureOpts ¶
type FeatureOpts struct {
EnableMetrics bool `json:"enableMetrics,omitempty" yaml:"enableMetrics,omitempty"` // 开启 metrics 记录
}
func NewDefaultFeatureOpts ¶
func NewDefaultFeatureOpts() *FeatureOpts
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func NewMysqlClientPool ¶
func NewMysqlClientPool(clientConf *Config, featureOpts *FeatureOpts) *Pool
func (*Pool) GetSession ¶
func (*Pool) GetUnSafeClient ¶
Click to show internal directories.
Click to hide internal directories.