mirror of
https://github.com/redis/go-redis.git
synced 2025-09-10 07:11:50 +03:00
DialTimeout defaults back to 5 seconds
This commit is contained in:
@@ -204,8 +204,8 @@ func TestCircuitBreaker(t *testing.T) {
|
||||
testError := errors.New("test error")
|
||||
|
||||
// Execute some operations
|
||||
cb.Execute(func() error { return testError }) // Failure
|
||||
cb.Execute(func() error { return testError }) // Failure
|
||||
cb.Execute(func() error { return testError }) // Failure
|
||||
cb.Execute(func() error { return testError }) // Failure
|
||||
|
||||
stats := cb.GetStats()
|
||||
|
||||
|
@@ -171,7 +171,7 @@ func TestApplyDefaults(t *testing.T) {
|
||||
}
|
||||
|
||||
resultCapped := configWithLargeQueue.ApplyDefaultsWithPoolSize(20) // Small pool size
|
||||
expectedCap := 20 * 5 // 5x pool size = 100
|
||||
expectedCap := 20 * 5 // 5x pool size = 100
|
||||
if resultCapped.HandoffQueueSize != expectedCap {
|
||||
t.Errorf("Expected HandoffQueueSize to be capped by 5x pool size (%d), got %d", expectedCap, resultCapped.HandoffQueueSize)
|
||||
}
|
||||
@@ -194,7 +194,7 @@ func TestApplyDefaults(t *testing.T) {
|
||||
}
|
||||
|
||||
resultVeryLarge := configWithVeryLargeQueue.ApplyDefaultsWithPoolSize(100) // Pool size 100
|
||||
expectedVeryLargeCap := 100 * 5 // 5x pool size = 500
|
||||
expectedVeryLargeCap := 100 * 5 // 5x pool size = 500
|
||||
if resultVeryLarge.HandoffQueueSize != expectedVeryLargeCap {
|
||||
t.Errorf("Expected very large HandoffQueueSize to be capped by 5x pool size (%d), got %d", expectedVeryLargeCap, resultVeryLarge.HandoffQueueSize)
|
||||
}
|
||||
@@ -305,7 +305,7 @@ func TestIntegrationWithApplyDefaults(t *testing.T) {
|
||||
t.Run("ProcessorWithPartialConfigAppliesDefaults", func(t *testing.T) {
|
||||
// Create a partial config with only some fields set
|
||||
partialConfig := &Config{
|
||||
MaxWorkers: 15, // Custom value (>= 10 to test preservation)
|
||||
MaxWorkers: 15, // Custom value (>= 10 to test preservation)
|
||||
LogLevel: logging.LogLevelInfo, // Custom value
|
||||
// Other fields left as zero values - should get defaults
|
||||
}
|
||||
|
@@ -454,7 +454,7 @@ func TestDialerRetryConfiguration(t *testing.T) {
|
||||
PoolSize: 1,
|
||||
PoolTimeout: time.Second,
|
||||
DialTimeout: time.Second,
|
||||
DialerRetries: 3, // Custom retry count
|
||||
DialerRetries: 3, // Custom retry count
|
||||
DialerRetryTimeout: 10 * time.Millisecond, // Fast retries for testing
|
||||
})
|
||||
defer connPool.Close()
|
||||
|
@@ -109,7 +109,7 @@ type Options struct {
|
||||
|
||||
// DialTimeout for establishing new connections.
|
||||
//
|
||||
// default: 10 seconds
|
||||
// default: 5 seconds
|
||||
DialTimeout time.Duration
|
||||
|
||||
// DialerRetries is the maximum number of retry attempts when dialing fails.
|
||||
@@ -285,7 +285,7 @@ func (opt *Options) init() {
|
||||
opt.Protocol = 3
|
||||
}
|
||||
if opt.DialTimeout == 0 {
|
||||
opt.DialTimeout = 10 * time.Second
|
||||
opt.DialTimeout = 5 * time.Second
|
||||
}
|
||||
if opt.DialerRetries == 0 {
|
||||
opt.DialerRetries = 5
|
||||
|
Reference in New Issue
Block a user