@@ -78,7 +78,7 @@ type Config struct {
7878 // RelaxedTimeout is the concrete timeout value to use during
7979 // MIGRATING/FAILING_OVER states to accommodate increased latency.
8080 // This applies to both read and write timeouts.
81- // Default: 30 seconds
81+ // Default: 10 seconds
8282 RelaxedTimeout time.Duration
8383
8484 // HandoffTimeout is the maximum time to wait for connection handoff to complete.
@@ -116,70 +116,10 @@ type Config struct {
116116 // Default: 1 (warnings)
117117 LogLevel int
118118
119- // Connection Handoff Configuration
120119 // MaxHandoffRetries is the maximum number of times to retry a failed handoff.
121120 // After this many retries, the connection will be removed from the pool.
122121 // Default: 3
123122 MaxHandoffRetries int
124-
125- // HandoffQueueTimeout is the maximum time to wait when queuing a handoff request.
126- // If the queue is full and this timeout expires, the handoff will be abandoned.
127- // Default: 5 seconds
128- HandoffQueueTimeout time.Duration
129-
130- // HandoffRetryDelay is the delay between handoff retry attempts.
131- // This prevents rapid retry loops and gives the system time to recover.
132- // Default: 1 second
133- HandoffRetryDelay time.Duration
134-
135- // Worker Scaling Configuration
136- // WorkerScaleDownDelay is how long to wait before scaling down workers after load decreases.
137- // This prevents rapid scaling cycles and maintains responsiveness for burst loads.
138- // Default: 30 seconds
139- WorkerScaleDownDelay time.Duration
140-
141- // WorkerScaleUpDelay is how long to wait before scaling up workers when queue depth increases.
142- // This prevents over-scaling for temporary spikes.
143- // Default: 5 seconds
144- WorkerScaleUpDelay time.Duration
145-
146- // WorkerIdleTimeout is how long a worker can be idle before being considered for scale-down.
147- // Workers idle longer than this may be terminated during scale-down operations.
148- // Default: 60 seconds
149- WorkerIdleTimeout time.Duration
150-
151- // Connection Validation Configuration
152- // ConnectionValidationTimeout is the timeout for validating new connections during handoff.
153- // This includes connection establishment and basic health checks.
154- // Default: 2 seconds
155- ConnectionValidationTimeout time.Duration
156-
157- // ConnectionHealthCheckInterval is how often to perform health checks on pooled connections.
158- // This helps detect and remove stale connections proactively.
159- // Default: 10 seconds
160- ConnectionHealthCheckInterval time.Duration
161-
162- // Operation Tracking Configuration
163- // OperationCleanupInterval is how often to clean up expired MOVING operations.
164- // This prevents memory leaks from operations that never complete.
165- // Default: 5 minutes
166- OperationCleanupInterval time.Duration
167-
168- // MaxActiveOperations is the maximum number of concurrent MOVING operations to track.
169- // This prevents unbounded memory growth under extreme load.
170- // Default: 10000
171- MaxActiveOperations int
172-
173- // Notification Processing Configuration
174- // NotificationBufferSize is the size of the buffer for incoming push notifications.
175- // Larger buffers can handle burst notification loads better.
176- // Default: 1000
177- NotificationBufferSize int
178-
179- // NotificationTimeout is the timeout for processing individual push notifications.
180- // This prevents hanging on malformed or problematic notifications.
181- // Default: 1 second
182- NotificationTimeout time.Duration
183123}
184124
185125func (c * Config ) IsEnabled () bool {
@@ -191,7 +131,7 @@ func DefaultConfig() *Config {
191131 return & Config {
192132 Enabled : MaintNotificationsAuto , // Enable by default for Redis Cloud
193133 EndpointType : EndpointTypeAuto , // Auto-detect based on connection
194- RelaxedTimeout : 30 * time .Second ,
134+ RelaxedTimeout : 10 * time .Second ,
195135 HandoffTimeout : 15 * time .Second ,
196136 MaxWorkers : 0 , // Auto-calculated based on pool size
197137 HandoffQueueSize : 0 , // Auto-calculated based on max workers
@@ -200,26 +140,7 @@ func DefaultConfig() *Config {
200140 LogLevel : 1 ,
201141
202142 // Connection Handoff Configuration
203- MaxHandoffRetries : 3 ,
204- HandoffQueueTimeout : 5 * time .Second ,
205- HandoffRetryDelay : 1 * time .Second ,
206-
207- // Worker Scaling Configuration
208- WorkerScaleDownDelay : 30 * time .Second ,
209- WorkerScaleUpDelay : 5 * time .Second ,
210- WorkerIdleTimeout : 60 * time .Second ,
211-
212- // Connection Validation Configuration
213- ConnectionValidationTimeout : 2 * time .Second ,
214- ConnectionHealthCheckInterval : 10 * time .Second ,
215-
216- // Operation Tracking Configuration
217- OperationCleanupInterval : 5 * time .Minute ,
218- MaxActiveOperations : 10000 ,
219-
220- // Notification Processing Configuration
221- NotificationBufferSize : 1000 ,
222- NotificationTimeout : 1 * time .Second ,
143+ MaxHandoffRetries : 3 ,
223144 }
224145}
225146
@@ -257,54 +178,12 @@ func (c *Config) Validate() error {
257178 return ErrInvalidEndpointType
258179 }
259180
260- // Validate new configuration fields
181+ // Validate configuration fields
261182 if c .MaxHandoffRetries < 1 || c .MaxHandoffRetries > 10 {
262183 return ErrInvalidHandoffRetries
263184 }
264185
265- if c .HandoffQueueTimeout <= 0 || c .HandoffQueueTimeout > time .Minute {
266- return ErrInvalidHandoffQueueTimeout
267- }
268-
269- if c .HandoffRetryDelay < 0 || c .HandoffRetryDelay > 10 * time .Second {
270- return ErrInvalidHandoffRetryDelay
271- }
272-
273- if c .WorkerScaleDownDelay < 0 || c .WorkerScaleDownDelay > 5 * time .Minute {
274- return ErrInvalidWorkerScaleDownDelay
275- }
276-
277- if c .WorkerScaleUpDelay < 0 || c .WorkerScaleUpDelay > time .Minute {
278- return ErrInvalidWorkerScaleUpDelay
279- }
280-
281- if c .WorkerIdleTimeout < 0 || c .WorkerIdleTimeout > 10 * time .Minute {
282- return ErrInvalidWorkerIdleTimeout
283- }
284-
285- if c .ConnectionValidationTimeout <= 0 || c .ConnectionValidationTimeout > 30 * time .Second {
286- return ErrInvalidConnectionValidationTimeout
287- }
288-
289- if c .ConnectionHealthCheckInterval < 0 || c .ConnectionHealthCheckInterval > time .Hour {
290- return ErrInvalidConnectionHealthCheckInterval
291- }
292-
293- if c .OperationCleanupInterval <= 0 || c .OperationCleanupInterval > time .Hour {
294- return ErrInvalidOperationCleanupInterval
295- }
296-
297- if c .MaxActiveOperations < 100 || c .MaxActiveOperations > 100000 {
298- return ErrInvalidMaxActiveOperations
299- }
300-
301- if c .NotificationBufferSize < 10 || c .NotificationBufferSize > 10000 {
302- return ErrInvalidNotificationBufferSize
303- }
304186
305- if c .NotificationTimeout <= 0 || c .NotificationTimeout > 30 * time .Second {
306- return ErrInvalidNotificationTimeout
307- }
308187
309188 return nil
310189}
@@ -398,78 +277,14 @@ func (c *Config) ApplyDefaultsWithPoolSize(poolSize int) *Config {
398277 // We'll use the provided value as-is, since 0 is valid
399278 result .LogLevel = c .LogLevel
400279
401- // Apply defaults for new configuration fields
280+ // Apply defaults for configuration fields
402281 if c .MaxHandoffRetries <= 0 {
403282 result .MaxHandoffRetries = defaults .MaxHandoffRetries
404283 } else {
405284 result .MaxHandoffRetries = c .MaxHandoffRetries
406285 }
407286
408- if c .HandoffQueueTimeout <= 0 {
409- result .HandoffQueueTimeout = defaults .HandoffQueueTimeout
410- } else {
411- result .HandoffQueueTimeout = c .HandoffQueueTimeout
412- }
413-
414- if c .HandoffRetryDelay < 0 {
415- result .HandoffRetryDelay = defaults .HandoffRetryDelay
416- } else {
417- result .HandoffRetryDelay = c .HandoffRetryDelay
418- }
419-
420- if c .WorkerScaleDownDelay < 0 {
421- result .WorkerScaleDownDelay = defaults .WorkerScaleDownDelay
422- } else {
423- result .WorkerScaleDownDelay = c .WorkerScaleDownDelay
424- }
425-
426- if c .WorkerScaleUpDelay < 0 {
427- result .WorkerScaleUpDelay = defaults .WorkerScaleUpDelay
428- } else {
429- result .WorkerScaleUpDelay = c .WorkerScaleUpDelay
430- }
431-
432- if c .WorkerIdleTimeout < 0 {
433- result .WorkerIdleTimeout = defaults .WorkerIdleTimeout
434- } else {
435- result .WorkerIdleTimeout = c .WorkerIdleTimeout
436- }
437-
438- if c .ConnectionValidationTimeout <= 0 {
439- result .ConnectionValidationTimeout = defaults .ConnectionValidationTimeout
440- } else {
441- result .ConnectionValidationTimeout = c .ConnectionValidationTimeout
442- }
443287
444- if c .ConnectionHealthCheckInterval < 0 {
445- result .ConnectionHealthCheckInterval = defaults .ConnectionHealthCheckInterval
446- } else {
447- result .ConnectionHealthCheckInterval = c .ConnectionHealthCheckInterval
448- }
449-
450- if c .OperationCleanupInterval <= 0 {
451- result .OperationCleanupInterval = defaults .OperationCleanupInterval
452- } else {
453- result .OperationCleanupInterval = c .OperationCleanupInterval
454- }
455-
456- if c .MaxActiveOperations <= 0 {
457- result .MaxActiveOperations = defaults .MaxActiveOperations
458- } else {
459- result .MaxActiveOperations = c .MaxActiveOperations
460- }
461-
462- if c .NotificationBufferSize <= 0 {
463- result .NotificationBufferSize = defaults .NotificationBufferSize
464- } else {
465- result .NotificationBufferSize = c .NotificationBufferSize
466- }
467-
468- if c .NotificationTimeout <= 0 {
469- result .NotificationTimeout = defaults .NotificationTimeout
470- } else {
471- result .NotificationTimeout = c .NotificationTimeout
472- }
473288
474289 return result
475290}
@@ -491,19 +306,8 @@ func (c *Config) Clone() *Config {
491306 ScaleDownDelay : c .ScaleDownDelay ,
492307 LogLevel : c .LogLevel ,
493308
494- // New configuration fields
495- MaxHandoffRetries : c .MaxHandoffRetries ,
496- HandoffQueueTimeout : c .HandoffQueueTimeout ,
497- HandoffRetryDelay : c .HandoffRetryDelay ,
498- WorkerScaleDownDelay : c .WorkerScaleDownDelay ,
499- WorkerScaleUpDelay : c .WorkerScaleUpDelay ,
500- WorkerIdleTimeout : c .WorkerIdleTimeout ,
501- ConnectionValidationTimeout : c .ConnectionValidationTimeout ,
502- ConnectionHealthCheckInterval : c .ConnectionHealthCheckInterval ,
503- OperationCleanupInterval : c .OperationCleanupInterval ,
504- MaxActiveOperations : c .MaxActiveOperations ,
505- NotificationBufferSize : c .NotificationBufferSize ,
506- NotificationTimeout : c .NotificationTimeout ,
309+ // Configuration fields
310+ MaxHandoffRetries : c .MaxHandoffRetries ,
507311 }
508312}
509313
0 commit comments