Documentation ¶
Index ¶
- Constants
- func NewConfigDbClient(ctx context.Context, name string, config Config) (gen_server.DbClient, error)
- func NewConfigMongoDbClient(ctx context.Context, name string, config Config) (gen_server.DbClient, error)
- func NewConfigMysqlClient(ctx context.Context, name string, config Config) (gen_server.DbClient, error)
- func NewConfigRedisClient(ctx context.Context, name string, config Config) (gen_server.DbClient, error)
- func NewDbClientFromUri(ctx context.Context, name string, uri string) (gen_server.DbClient, error)
- type Config
- type MigrateConnectTimeout
- type MigrateDropIndex
- type MigrateOption
- type MigrateOptions
- type MongoDbClient
- type MysqlClient
- type RedisClient
Constants ¶
View Source
const ( MONGODB_NAME = "mongo" REDIS_NAME = "redis" MYSQL_NAME = "mysql" )
Variables ¶
This section is empty.
Functions ¶
func NewConfigDbClient ¶
func NewConfigDbClient(ctx context.Context, name string, config Config) (gen_server.DbClient, error)
根据配置构造db client
func NewConfigMongoDbClient ¶
func NewConfigMongoDbClient(ctx context.Context, name string, config Config) (gen_server.DbClient, error)
根据配置构造mongodb client
func NewConfigMysqlClient ¶
func NewConfigMysqlClient(ctx context.Context, name string, config Config) (gen_server.DbClient, error)
根据配置构造mysql client
func NewConfigRedisClient ¶
func NewConfigRedisClient(ctx context.Context, name string, config Config) (gen_server.DbClient, error)
根据配置构造redis client
func NewDbClientFromUri ¶
根据url构造db client
Types ¶
type Config ¶
type Config struct { Driver string `yaml:"driver"` Host string `yaml:"host"` Port int `yaml:"port"` User string `yaml:"user"` Password string `yaml:"password"` Db string `yaml:"db"` Query string `yaml:"query"` MaxOpenConns int `yaml:"max-open-conns"` MaxIdleConns int `yaml:"max-idle-conns"` ConnMaxIdleTime time.Duration `yaml:"conn-max-idle-time"` ConnMaxLifetime time.Duration `yaml:"conn-max-lifetime"` ConnnectTimeout time.Duration `yaml:"connect-timeout"` }
type MigrateConnectTimeout ¶
type MigrateConnectTimeout struct {
// contains filtered or unexported fields
}
func WithMigrateConnectTimeout ¶
func WithMigrateConnectTimeout(timeout int64) MigrateConnectTimeout
设置连接超时时间
func (MigrateConnectTimeout) ConfigMigrateOptions ¶
func (opt MigrateConnectTimeout) ConfigMigrateOptions(opts *MigrateOptions)
type MigrateDropIndex ¶
type MigrateDropIndex struct {
// contains filtered or unexported fields
}
func (MigrateDropIndex) ConfigMigrateOptions ¶
func (opt MigrateDropIndex) ConfigMigrateOptions(opts *MigrateOptions)
type MigrateOption ¶
type MigrateOption interface {
ConfigMigrateOptions(opts *MigrateOptions)
}
type MigrateOptions ¶
========= migrate选项 ==================
type MongoDbClient ¶
type MongoDbClient struct {
// contains filtered or unexported fields
}
mongodb客户端
func (*MongoDbClient) GetMongoClient ¶
func (self *MongoDbClient) GetMongoClient() *mongo.Client
func (*MongoDbClient) GetMongoDatabase ¶
func (self *MongoDbClient) GetMongoDatabase() *mongo.Database
func (*MongoDbClient) Uri ¶
func (self *MongoDbClient) Uri() string
type MysqlClient ¶
type MysqlClient struct {
// contains filtered or unexported fields
}
mysql客户端
func (*MysqlClient) GetMysqlClient ¶
func (self *MysqlClient) GetMysqlClient() *sql.DB
func (*MysqlClient) Uri ¶
func (self *MysqlClient) Uri() string
type RedisClient ¶
type RedisClient struct {
// contains filtered or unexported fields
}
redis客户端
func (*RedisClient) GetRedisClient ¶
func (self *RedisClient) GetRedisClient() *redis.Client
func (*RedisClient) Uri ¶
func (self *RedisClient) Uri() string
Click to show internal directories.
Click to hide internal directories.