1
0
mirror of https://github.com/redis/go-redis.git synced 2025-09-08 19:52:07 +03:00

DialTimeout defaults back to 5 seconds

This commit is contained in:
Nedyalko Dyakov
2025-09-04 17:51:28 +03:00
parent 8aecdb890a
commit 0196b9a9bd
4 changed files with 46 additions and 46 deletions

View File

@@ -204,8 +204,8 @@ func TestCircuitBreaker(t *testing.T) {
testError := errors.New("test error") testError := errors.New("test error")
// Execute some operations // 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() stats := cb.GetStats()

View File

@@ -171,7 +171,7 @@ func TestApplyDefaults(t *testing.T) {
} }
resultCapped := configWithLargeQueue.ApplyDefaultsWithPoolSize(20) // Small pool size 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 { if resultCapped.HandoffQueueSize != expectedCap {
t.Errorf("Expected HandoffQueueSize to be capped by 5x pool size (%d), got %d", expectedCap, resultCapped.HandoffQueueSize) 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 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 { if resultVeryLarge.HandoffQueueSize != expectedVeryLargeCap {
t.Errorf("Expected very large HandoffQueueSize to be capped by 5x pool size (%d), got %d", expectedVeryLargeCap, resultVeryLarge.HandoffQueueSize) 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) { t.Run("ProcessorWithPartialConfigAppliesDefaults", func(t *testing.T) {
// Create a partial config with only some fields set // Create a partial config with only some fields set
partialConfig := &Config{ partialConfig := &Config{
MaxWorkers: 15, // Custom value (>= 10 to test preservation) MaxWorkers: 15, // Custom value (>= 10 to test preservation)
LogLevel: logging.LogLevelInfo, // Custom value LogLevel: logging.LogLevelInfo, // Custom value
// Other fields left as zero values - should get defaults // Other fields left as zero values - should get defaults
} }

View File

@@ -454,7 +454,7 @@ func TestDialerRetryConfiguration(t *testing.T) {
PoolSize: 1, PoolSize: 1,
PoolTimeout: time.Second, PoolTimeout: time.Second,
DialTimeout: time.Second, DialTimeout: time.Second,
DialerRetries: 3, // Custom retry count DialerRetries: 3, // Custom retry count
DialerRetryTimeout: 10 * time.Millisecond, // Fast retries for testing DialerRetryTimeout: 10 * time.Millisecond, // Fast retries for testing
}) })
defer connPool.Close() defer connPool.Close()

View File

@@ -109,7 +109,7 @@ type Options struct {
// DialTimeout for establishing new connections. // DialTimeout for establishing new connections.
// //
// default: 10 seconds // default: 5 seconds
DialTimeout time.Duration DialTimeout time.Duration
// DialerRetries is the maximum number of retry attempts when dialing fails. // DialerRetries is the maximum number of retry attempts when dialing fails.
@@ -285,7 +285,7 @@ func (opt *Options) init() {
opt.Protocol = 3 opt.Protocol = 3
} }
if opt.DialTimeout == 0 { if opt.DialTimeout == 0 {
opt.DialTimeout = 10 * time.Second opt.DialTimeout = 5 * time.Second
} }
if opt.DialerRetries == 0 { if opt.DialerRetries == 0 {
opt.DialerRetries = 5 opt.DialerRetries = 5