feat: allow more control on redis client configuration
Cadoles/bouncer/pipeline/head This commit was not built
Details
Cadoles/bouncer/pipeline/head This commit was not built
Details
This commit is contained in:
parent
69501f6302
commit
11375e546f
|
@ -15,8 +15,16 @@ type RedisConfig struct {
|
||||||
WriteTimeout InterpolatedDuration `yaml:"writeTimeout"`
|
WriteTimeout InterpolatedDuration `yaml:"writeTimeout"`
|
||||||
DialTimeout InterpolatedDuration `yaml:"dialTimeout"`
|
DialTimeout InterpolatedDuration `yaml:"dialTimeout"`
|
||||||
LockMaxRetries InterpolatedInt `yaml:"lockMaxRetries"`
|
LockMaxRetries InterpolatedInt `yaml:"lockMaxRetries"`
|
||||||
|
RouteByLatency InterpolatedBool `yaml:"routeByLatency"`
|
||||||
|
ContextTimeoutEnabled InterpolatedBool `yaml:"contextTimeoutEnabled"`
|
||||||
MaxRetries InterpolatedInt `yaml:"maxRetries"`
|
MaxRetries InterpolatedInt `yaml:"maxRetries"`
|
||||||
PingInterval InterpolatedDuration `yaml:"pingInterval"`
|
PingInterval InterpolatedDuration `yaml:"pingInterval"`
|
||||||
|
PoolSize InterpolatedInt `yaml:"poolSize"`
|
||||||
|
PoolTimeout InterpolatedDuration `yaml:"poolTimeout"`
|
||||||
|
MinIdleConns InterpolatedInt `yaml:"minIdleConns"`
|
||||||
|
MaxIdleConns InterpolatedInt `yaml:"maxIdleConns"`
|
||||||
|
ConnMaxIdleTime InterpolatedDuration `yaml:"connMaxIdleTime"`
|
||||||
|
ConnMaxLifetime InterpolatedDuration `yaml:"connMaxLifeTime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDefaultRedisConfig() RedisConfig {
|
func NewDefaultRedisConfig() RedisConfig {
|
||||||
|
@ -29,5 +37,7 @@ func NewDefaultRedisConfig() RedisConfig {
|
||||||
LockMaxRetries: 10,
|
LockMaxRetries: 10,
|
||||||
MaxRetries: 3,
|
MaxRetries: 3,
|
||||||
PingInterval: InterpolatedDuration(30 * time.Second),
|
PingInterval: InterpolatedDuration(30 * time.Second),
|
||||||
|
ContextTimeoutEnabled: true,
|
||||||
|
RouteByLatency: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,15 @@ func newRedisClient(conf config.RedisConfig) redis.UniversalClient {
|
||||||
ReadTimeout: time.Duration(conf.ReadTimeout),
|
ReadTimeout: time.Duration(conf.ReadTimeout),
|
||||||
WriteTimeout: time.Duration(conf.WriteTimeout),
|
WriteTimeout: time.Duration(conf.WriteTimeout),
|
||||||
DialTimeout: time.Duration(conf.DialTimeout),
|
DialTimeout: time.Duration(conf.DialTimeout),
|
||||||
RouteByLatency: true,
|
RouteByLatency: bool(conf.RouteByLatency),
|
||||||
ContextTimeoutEnabled: true,
|
ContextTimeoutEnabled: bool(conf.ContextTimeoutEnabled),
|
||||||
MaxRetries: int(conf.MaxRetries),
|
MaxRetries: int(conf.MaxRetries),
|
||||||
|
PoolSize: int(conf.PoolSize),
|
||||||
|
PoolTimeout: time.Duration(conf.PoolTimeout),
|
||||||
|
MinIdleConns: int(conf.MinIdleConns),
|
||||||
|
MaxIdleConns: int(conf.MaxIdleConns),
|
||||||
|
ConnMaxIdleTime: time.Duration(conf.ConnMaxIdleTime),
|
||||||
|
ConnMaxLifetime: time.Duration(conf.ConnMaxLifetime),
|
||||||
})
|
})
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|
Loading…
Reference in New Issue