From a13a4c0cb31e0b9b045397893c56c7c8299adbf3 Mon Sep 17 00:00:00 2001 From: Tetrergeru Date: Mon, 2 Dec 2024 09:21:56 +0100 Subject: [PATCH 1/2] feat: Pass max_redirects to config --- cmd/config.go | 3 +++ cmd/config_test.go | 6 ++++++ database/redis/config.go | 1 + database/redis/database.go | 1 + local/checker.yml | 1 + 5 files changed, 12 insertions(+) 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/checker.yml b/local/checker.yml index 30f7e0bb9..9524def40 100644 --- a/local/checker.yml +++ b/local/checker.yml @@ -2,6 +2,7 @@ redis: addrs: "redis:6379" metrics_ttl: 3h + max_redirects: 10 telemetry: graphite: enabled: true From e12dd6bf1e66d4abbfe937b0fd4ac002eae80ecc Mon Sep 17 00:00:00 2001 From: Tetrergeru Date: Tue, 3 Dec 2024 11:45:30 +0100 Subject: [PATCH 2/2] Remove unneeded values in local configs --- local/api.yml | 2 -- local/checker.yml | 1 - 2 files changed, 3 deletions(-) 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 diff --git a/local/checker.yml b/local/checker.yml index 9524def40..30f7e0bb9 100644 --- a/local/checker.yml +++ b/local/checker.yml @@ -2,7 +2,6 @@ redis: addrs: "redis:6379" metrics_ttl: 3h - max_redirects: 10 telemetry: graphite: enabled: true