Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Pass max_redirects to config #1128

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 0 additions & 2 deletions local/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
redis:
addrs: "redis:6379"
metrics_ttl: 3h
min_retry_backoff: 1s
max_retry_backoff: 10s
telemetry:
graphite:
enabled: true
Expand Down
Loading