Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func InitGorm ¶
func InitGorm(c *MySQLConfig) (db *gorm.DB)
Types ¶
type MySQLConfig ¶
type MySQLConfig struct { DSN string `json:"dsn" toml:"dsn" yaml:"dsn"` // data source name. MaxOpenConn int `json:"max_open_conn" toml:"max_open_conn" yaml:"max_open_conn"` // pool, e.g:10 MaxIdleConn int `json:"max_idle_conn" toml:"max_idle_conn" yaml:"max_idle_conn"` // pool, e.g:100 MaxConnTimeout xtime.Duration `json:"max_conn_timeout" toml:"max_conn_timeout" yaml:"max_conn_timeout"` // connect max life time. Unmarshal config file e.g: 10s、2m、1m10s LogLevel string `json:"log_level" toml:"log_level" yaml:"log_level"` // enum: info、warn、error、silent, default warn Colorful bool `json:"colorful" toml:"colorful" yaml:"colorful"` // is colorful log, default false SlowThreshold xtime.Duration `json:"slow_threshold" toml:"slow_threshold" yaml:"slow_threshold"` // slow sql log. Unmarshal config file e.g: 100ms、200ms、300ms、1s, default 200ms }
MySQLConfig mysql config.
type Redis ¶
type Redis struct {
Redis *redis.Client
}
func InitRedis ¶
func InitRedis(c *RedisConfig) (r *Redis)
type RedisCluster ¶
type RedisCluster struct {
Redis *redis.ClusterClient
}
func InitRedisCluster ¶
func InitRedisCluster(c *RedisConfig) (rc *RedisCluster)
func (*RedisCluster) Transaction ¶
func (r *RedisCluster) Transaction(ctx context.Context, fc func(tx redis.Pipeliner) error) error
type RedisConfig ¶
type RedisConfig struct { Addrs []string `json:"addrs" yaml:"addrs" toml:"addrs"` Password string `json:"password" yaml:"password" toml:"password"` DB int `json:"db" yaml:"db" toml:"db"` ReadTimeout xtime.Duration `json:"read_timeout" yaml:"read_timeout" toml:"read_timeout"` WriteTimeout xtime.Duration `json:"write_timeout" yaml:"write_timeout" toml:"write_timeout"` }
RedisConfig redis config.
Click to show internal directories.
Click to hide internal directories.