Skip to content

Commit

Permalink
feat: Pass max_redirects to config
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetrergeru committed Dec 2, 2024
1 parent 520c968 commit a13a4c0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down
6 changes: 6 additions & 0 deletions cmd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions database/redis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type DatabaseConfig struct {
ReadTimeout time.Duration
WriteTimeout time.Duration

MaxRedirects int
MaxRetries int
MinRetryBackoff time.Duration
MaxRetryBackoff time.Duration
Expand Down
1 change: 1 addition & 0 deletions database/redis/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions local/checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
redis:
addrs: "redis:6379"
metrics_ttl: 3h
max_redirects: 10
telemetry:
graphite:
enabled: true
Expand Down

0 comments on commit a13a4c0

Please sign in to comment.