Files
bouncer/internal/config/redis.go

47 lines
2.0 KiB
Go
Raw Normal View History

2023-04-24 20:52:12 +02:00
package config
2024-02-15 15:17:57 +01:00
import "time"
2023-04-24 20:52:12 +02:00
const (
RedisModeSimple = "simple"
RedisModeSentinel = "sentinel"
RedisModeCluster = "cluster"
)
type RedisConfig struct {
Adresses InterpolatedStringSlice `yaml:"addresses"`
Master InterpolatedString `yaml:"master"`
ReadTimeout *InterpolatedDuration `yaml:"readTimeout"`
WriteTimeout *InterpolatedDuration `yaml:"writeTimeout"`
DialTimeout *InterpolatedDuration `yaml:"dialTimeout"`
LockMaxRetries InterpolatedInt `yaml:"lockMaxRetries"`
RouteByLatency InterpolatedBool `yaml:"routeByLatency"`
ContextTimeoutEnabled InterpolatedBool `yaml:"contextTimeoutEnabled"`
MaxRetries InterpolatedInt `yaml:"maxRetries"`
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"`
2023-04-24 20:52:12 +02:00
}
func NewDefaultRedisConfig() RedisConfig {
return RedisConfig{
Adresses: InterpolatedStringSlice{"localhost:6379"},
Master: "",
ReadTimeout: NewInterpolatedDuration(30 * time.Second),
WriteTimeout: NewInterpolatedDuration(30 * time.Second),
DialTimeout: NewInterpolatedDuration(30 * time.Second),
PoolTimeout: NewInterpolatedDuration(31 * time.Second),
LockMaxRetries: 10,
MaxRetries: 3,
PingInterval: NewInterpolatedDuration(30 * time.Second),
ContextTimeoutEnabled: true,
RouteByLatency: true,
ConnMaxIdleTime: NewInterpolatedDuration(1 * time.Minute),
ConnMaxLifetime: NewInterpolatedDuration(5 * time.Minute),
2023-04-24 20:52:12 +02:00
}
}