diff --git a/cmd/config.go b/cmd/config.go index c03ad048a..c81bb06e8 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -46,6 +46,8 @@ type RedisConfig struct { ReadTimeout string `yaml:"read_timeout"` // Write-operation timeout. Default is ReadTimeout seconds. WriteTimeout string `yaml:"write_timeout"` + // MaxRetries count of redirects. + MaxRedirects int `yaml:"max_redirects"` // MaxRetries count of retries. MaxRetries int `yaml:"max_retries"` // Minimum backoff between retries. Used to calculate exponential backoff. Default value is 0 @@ -71,6 +73,7 @@ func (config *RedisConfig) GetSettings() redis.DatabaseConfig { Password: config.Password, SentinelUsername: config.SentinelUsername, SentinelPassword: config.SentinelPassword, + MaxRedirects: config.MaxRedirects, MaxRetries: config.MaxRetries, MinRetryBackoff: to.Duration(config.MinRetryBackoff), MaxRetryBackoff: to.Duration(config.MaxRetryBackoff), diff --git a/cmd/config_test.go b/cmd/config_test.go index f41583d00..68881c6c1 100644 --- a/cmd/config_test.go +++ b/cmd/config_test.go @@ -32,7 +32,10 @@ func TestRedisConfig(t *testing.T) { DialTimeout: "1m", ReadTimeout: "1m", WriteTimeout: "1m", + MinRetryBackoff: "10s", + MaxRetryBackoff: "20s", MaxRetries: 3, + MaxRedirects: 4, ReadOnly: true, RouteByLatency: true, RouteRandomly: true, @@ -49,7 +52,10 @@ func TestRedisConfig(t *testing.T) { DialTimeout: time.Minute, ReadTimeout: time.Minute, WriteTimeout: time.Minute, + MinRetryBackoff: time.Second * 10, + MaxRetryBackoff: time.Second * 20, MaxRetries: 3, + MaxRedirects: 4, ReadOnly: true, RouteByLatency: true, RouteRandomly: true, diff --git a/database/redis/config.go b/database/redis/config.go index 52b2ea08f..b5c969213 100644 --- a/database/redis/config.go +++ b/database/redis/config.go @@ -18,6 +18,7 @@ type DatabaseConfig struct { ReadTimeout time.Duration WriteTimeout time.Duration + MaxRedirects int MaxRetries int MinRetryBackoff time.Duration MaxRetryBackoff time.Duration diff --git a/database/redis/database.go b/database/redis/database.go index 54077a215..e73c01750 100644 --- a/database/redis/database.go +++ b/database/redis/database.go @@ -65,6 +65,7 @@ func NewDatabase(logger moira.Logger, config DatabaseConfig, nh NotificationHist ReadTimeout: config.ReadTimeout, WriteTimeout: config.WriteTimeout, + MaxRedirects: config.MaxRedirects, MaxRetries: config.MaxRetries, MinRetryBackoff: config.MinRetryBackoff, MaxRetryBackoff: config.MaxRetryBackoff, diff --git a/local/api.yml b/local/api.yml index 40ab79dcf..1f47563d3 100644 --- a/local/api.yml +++ b/local/api.yml @@ -2,8 +2,6 @@ redis: addrs: "redis:6379" metrics_ttl: 3h - min_retry_backoff: 1s - max_retry_backoff: 10s telemetry: graphite: enabled: true