Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ProviderSet = wire.NewSet( NewMySQL, NewRedis, wire.Bind(new(redis.UniversalClient), new(*redis.Client)), )
ProviderSet is db providers.
Functions ¶
func NewMySQL ¶
func NewMySQL(opts *MySQLOptions) (*gorm.DB, error)
NewMySQL create a new gorm db instance with the given options.
func NewPostgreSQL ¶
func NewPostgreSQL(opts *PostgreSQLOptions) (*gorm.DB, error)
NewPostgreSQL create a new gorm db instance with the given options.
func NewRedis ¶
func NewRedis(opts *RedisOptions) (*redis.Client, error)
NewRedis create a new redis db instance with the given options.
Types ¶
type MySQLOptions ¶
type MySQLOptions struct {
Addr string
Username string
Password string
Database string
MaxIdleConnections int
MaxOpenConnections int
MaxConnectionLifeTime time.Duration
// +optional
Logger logger.Interface
}
MySQLOptions defines options for mysql database.
type PostgreSQLOptions ¶
type PostgreSQLOptions struct {
Addr string
Username string
Password string
Database string
MaxIdleConnections int
MaxOpenConnections int
MaxConnectionLifeTime time.Duration
// +optional
Logger logger.Interface
}
PostgreSQLOptions defines options for PostgreSQL database.
func (*PostgreSQLOptions) DSN ¶
func (o *PostgreSQLOptions) DSN() string
DSN return DSN from PostgreSQLOptions.
type RedisOptions ¶
type RedisOptions struct {
Addr string
Username string
Password string
Database int
MaxRetries int
MinIdleConns int
DialTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
PoolTimeout time.Duration
PoolSize int
}
RedisOptions defines options for redis database.
type TracePlugin ¶
type TracePlugin struct{}
TracePlugin defines gorm plugin used to trace sql.
func (*TracePlugin) Initialize ¶
func (op *TracePlugin) Initialize(db *gorm.DB) (err error)
Initialize initialize the trace plugin.
func (*TracePlugin) Name ¶
func (op *TracePlugin) Name() string
Name returns the name of trace plugin.
Click to show internal directories.
Click to hide internal directories.