Documentation
¶
Index ¶
- func NewPBGorm(params ...interface{}) (interface{}, error)
- func WithConfigPath(configPath string) contract.DBOption
- func WithGormConfig(config *gorm.Config) contract.DBOption
- type DBConfig
- type GormProvider
- func (pb *GormProvider) Boot(container framework.Container) error
- func (pb *GormProvider) IsDefer() bool
- func (pb *GormProvider) Name() string
- func (pb *GormProvider) Params(container framework.Container) []interface{}
- func (pb *GormProvider) Register(container framework.Container) framework.NewInstance
- type OrmLogger
- func (o *OrmLogger) Error(ctx context.Context, msg string, i ...interface{})
- func (o *OrmLogger) Info(ctx context.Context, msg string, i ...interface{})
- func (o *OrmLogger) LogMode(logger.LogLevel) logger.Interface
- func (o *OrmLogger) Trace(ctx context.Context, begin time.Time, ...)
- func (o *OrmLogger) Warn(ctx context.Context, msg string, i ...interface{})
- type PBGorm
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithConfigPath ¶
WithConfigPath 从database.yaml加载配置
Types ¶
type DBConfig ¶
type DBConfig struct { // 以下配置关于dsn WriteTimeout string `yaml:"write_timeout"` Loc string `yaml:"loc"` Port int `yaml:"port"` ReadTimeout string `yaml:"read_timeout"` Charset string `yaml:"charset"` ParseTime bool `yaml:"parse_time"` Protocol string `yaml:"protocol"` Dsn string `yaml:"dsn"` Database string `yaml:"database"` Collation string `yaml:"collation"` Timeout string `yaml:"timeout"` Username string `yaml:"username"` Password string `yaml:"password"` Driver string `yaml:"driver"` Host string `yaml:"host"` // 以下配置关于连接池 ConnMaxIdle int `yaml:"conn_max_idle"` // 最大空闲连接数 ConnMaxOpen int `yaml:"conn_max_open"` // 最大连接数 ConnMaxLifetime string `yaml:"conn_max_lifetime"` // 连接最大生命周期 ConnMaxIdletime string `yaml:"conn_max_idletime"` // 空闲最大生命周期 }
DBConfig 代表数据库连接的所有配置
func GetBaseConfig ¶
GetBaseConfig 读取database.yaml根目录结构
type GormProvider ¶
type GormProvider struct{}
GormProvider 提供App的具体实现方法
func (*GormProvider) Boot ¶
func (pb *GormProvider) Boot(container framework.Container) error
Boot 启动调用
func (*GormProvider) Params ¶
func (pb *GormProvider) Params(container framework.Container) []interface{}
Params 获取初始化参数
func (*GormProvider) Register ¶
func (pb *GormProvider) Register(container framework.Container) framework.NewInstance
Register 注册方法
type OrmLogger ¶
type OrmLogger struct {
// contains filtered or unexported fields
}
OrmLogger orm的日志实现类, 实现了gorm.Logger.Interface
Click to show internal directories.
Click to hide internal directories.