@@ -89,7 +89,18 @@ type FailoverOptions struct {
8989 MinRetryBackoff time.Duration
9090 MaxRetryBackoff time.Duration
9191
92- DialTimeout time.Duration
92+ DialTimeout time.Duration
93+
94+ // DialerRetries is the maximum number of retry attempts when dialing fails.
95+ //
96+ // default: 5
97+ DialerRetries int
98+
99+ // DialerRetryTimeout is the backoff duration between retry attempts.
100+ //
101+ // default: 100 milliseconds
102+ DialerRetryTimeout time.Duration
103+
93104 ReadTimeout time.Duration
94105 WriteTimeout time.Duration
95106 ContextTimeoutEnabled bool
@@ -110,7 +121,12 @@ type FailoverOptions struct {
110121
111122 PoolFIFO bool
112123
113- PoolSize int
124+ PoolSize int
125+
126+ // MaxConcurrentDials is the maximum number of concurrent connection creation goroutines.
127+ // If <= 0, defaults to PoolSize. If > PoolSize, it will be capped at PoolSize.
128+ MaxConcurrentDials int
129+
114130 PoolTimeout time.Duration
115131 MinIdleConns int
116132 MaxIdleConns int
@@ -141,6 +157,10 @@ type FailoverOptions struct {
141157
142158 UnstableResp3 bool
143159
160+ // PushNotificationProcessor is the processor for handling push notifications.
161+ // If nil, a default processor will be created for RESP3 connections.
162+ PushNotificationProcessor push.NotificationProcessor
163+
144164 // MaintNotificationsConfig is not supported for FailoverClients at the moment
145165 // MaintNotificationsConfig provides custom configuration for maintnotifications upgrades.
146166 // When MaintNotificationsConfig.Mode is not "disabled", the client will handle
@@ -174,27 +194,32 @@ func (opt *FailoverOptions) clientOptions() *Options {
174194 ReadBufferSize : opt .ReadBufferSize ,
175195 WriteBufferSize : opt .WriteBufferSize ,
176196
177- DialTimeout : opt .DialTimeout ,
178- ReadTimeout : opt .ReadTimeout ,
179- WriteTimeout : opt .WriteTimeout ,
197+ DialTimeout : opt .DialTimeout ,
198+ DialerRetries : opt .DialerRetries ,
199+ DialerRetryTimeout : opt .DialerRetryTimeout ,
200+ ReadTimeout : opt .ReadTimeout ,
201+ WriteTimeout : opt .WriteTimeout ,
202+
180203 ContextTimeoutEnabled : opt .ContextTimeoutEnabled ,
181204
182- PoolFIFO : opt .PoolFIFO ,
183- PoolSize : opt .PoolSize ,
184- PoolTimeout : opt .PoolTimeout ,
185- MinIdleConns : opt .MinIdleConns ,
186- MaxIdleConns : opt .MaxIdleConns ,
187- MaxActiveConns : opt .MaxActiveConns ,
188- ConnMaxIdleTime : opt .ConnMaxIdleTime ,
189- ConnMaxLifetime : opt .ConnMaxLifetime ,
205+ PoolFIFO : opt .PoolFIFO ,
206+ PoolSize : opt .PoolSize ,
207+ MaxConcurrentDials : opt .MaxConcurrentDials ,
208+ PoolTimeout : opt .PoolTimeout ,
209+ MinIdleConns : opt .MinIdleConns ,
210+ MaxIdleConns : opt .MaxIdleConns ,
211+ MaxActiveConns : opt .MaxActiveConns ,
212+ ConnMaxIdleTime : opt .ConnMaxIdleTime ,
213+ ConnMaxLifetime : opt .ConnMaxLifetime ,
190214
191215 TLSConfig : opt .TLSConfig ,
192216
193217 DisableIdentity : opt .DisableIdentity ,
194218 DisableIndentity : opt .DisableIndentity ,
195219
196- IdentitySuffix : opt .IdentitySuffix ,
197- UnstableResp3 : opt .UnstableResp3 ,
220+ IdentitySuffix : opt .IdentitySuffix ,
221+ UnstableResp3 : opt .UnstableResp3 ,
222+ PushNotificationProcessor : opt .PushNotificationProcessor ,
198223
199224 MaintNotificationsConfig : & maintnotifications.Config {
200225 Mode : maintnotifications .ModeDisabled ,
@@ -222,27 +247,32 @@ func (opt *FailoverOptions) sentinelOptions(addr string) *Options {
222247 ReadBufferSize : 4096 ,
223248 WriteBufferSize : 4096 ,
224249
225- DialTimeout : opt .DialTimeout ,
226- ReadTimeout : opt .ReadTimeout ,
227- WriteTimeout : opt .WriteTimeout ,
250+ DialTimeout : opt .DialTimeout ,
251+ DialerRetries : opt .DialerRetries ,
252+ DialerRetryTimeout : opt .DialerRetryTimeout ,
253+ ReadTimeout : opt .ReadTimeout ,
254+ WriteTimeout : opt .WriteTimeout ,
255+
228256 ContextTimeoutEnabled : opt .ContextTimeoutEnabled ,
229257
230- PoolFIFO : opt .PoolFIFO ,
231- PoolSize : opt .PoolSize ,
232- PoolTimeout : opt .PoolTimeout ,
233- MinIdleConns : opt .MinIdleConns ,
234- MaxIdleConns : opt .MaxIdleConns ,
235- MaxActiveConns : opt .MaxActiveConns ,
236- ConnMaxIdleTime : opt .ConnMaxIdleTime ,
237- ConnMaxLifetime : opt .ConnMaxLifetime ,
258+ PoolFIFO : opt .PoolFIFO ,
259+ PoolSize : opt .PoolSize ,
260+ MaxConcurrentDials : opt .MaxConcurrentDials ,
261+ PoolTimeout : opt .PoolTimeout ,
262+ MinIdleConns : opt .MinIdleConns ,
263+ MaxIdleConns : opt .MaxIdleConns ,
264+ MaxActiveConns : opt .MaxActiveConns ,
265+ ConnMaxIdleTime : opt .ConnMaxIdleTime ,
266+ ConnMaxLifetime : opt .ConnMaxLifetime ,
238267
239268 TLSConfig : opt .TLSConfig ,
240269
241270 DisableIdentity : opt .DisableIdentity ,
242271 DisableIndentity : opt .DisableIndentity ,
243272
244- IdentitySuffix : opt .IdentitySuffix ,
245- UnstableResp3 : opt .UnstableResp3 ,
273+ IdentitySuffix : opt .IdentitySuffix ,
274+ UnstableResp3 : opt .UnstableResp3 ,
275+ PushNotificationProcessor : opt .PushNotificationProcessor ,
246276
247277 MaintNotificationsConfig : & maintnotifications.Config {
248278 Mode : maintnotifications .ModeDisabled ,
@@ -276,26 +306,31 @@ func (opt *FailoverOptions) clusterOptions() *ClusterOptions {
276306 ReadBufferSize : opt .ReadBufferSize ,
277307 WriteBufferSize : opt .WriteBufferSize ,
278308
279- DialTimeout : opt .DialTimeout ,
280- ReadTimeout : opt .ReadTimeout ,
281- WriteTimeout : opt .WriteTimeout ,
309+ DialTimeout : opt .DialTimeout ,
310+ DialerRetries : opt .DialerRetries ,
311+ DialerRetryTimeout : opt .DialerRetryTimeout ,
312+ ReadTimeout : opt .ReadTimeout ,
313+ WriteTimeout : opt .WriteTimeout ,
314+
282315 ContextTimeoutEnabled : opt .ContextTimeoutEnabled ,
283316
284- PoolFIFO : opt .PoolFIFO ,
285- PoolSize : opt .PoolSize ,
286- PoolTimeout : opt .PoolTimeout ,
287- MinIdleConns : opt .MinIdleConns ,
288- MaxIdleConns : opt .MaxIdleConns ,
289- MaxActiveConns : opt .MaxActiveConns ,
290- ConnMaxIdleTime : opt .ConnMaxIdleTime ,
291- ConnMaxLifetime : opt .ConnMaxLifetime ,
317+ PoolFIFO : opt .PoolFIFO ,
318+ PoolSize : opt .PoolSize ,
319+ MaxConcurrentDials : opt .MaxConcurrentDials ,
320+ PoolTimeout : opt .PoolTimeout ,
321+ MinIdleConns : opt .MinIdleConns ,
322+ MaxIdleConns : opt .MaxIdleConns ,
323+ MaxActiveConns : opt .MaxActiveConns ,
324+ ConnMaxIdleTime : opt .ConnMaxIdleTime ,
325+ ConnMaxLifetime : opt .ConnMaxLifetime ,
292326
293327 TLSConfig : opt .TLSConfig ,
294328
295- DisableIdentity : opt .DisableIdentity ,
296- DisableIndentity : opt .DisableIndentity ,
297- IdentitySuffix : opt .IdentitySuffix ,
298- FailingTimeoutSeconds : opt .FailingTimeoutSeconds ,
329+ DisableIdentity : opt .DisableIdentity ,
330+ DisableIndentity : opt .DisableIndentity ,
331+ IdentitySuffix : opt .IdentitySuffix ,
332+ FailingTimeoutSeconds : opt .FailingTimeoutSeconds ,
333+ PushNotificationProcessor : opt .PushNotificationProcessor ,
299334
300335 MaintNotificationsConfig : & maintnotifications.Config {
301336 Mode : maintnotifications .ModeDisabled ,
@@ -399,11 +434,14 @@ func setupFailoverConnParams(u *url.URL, o *FailoverOptions) (*FailoverOptions,
399434 o .MinRetryBackoff = q .duration ("min_retry_backoff" )
400435 o .MaxRetryBackoff = q .duration ("max_retry_backoff" )
401436 o .DialTimeout = q .duration ("dial_timeout" )
437+ o .DialerRetries = q .int ("dialer_retries" )
438+ o .DialerRetryTimeout = q .duration ("dialer_retry_timeout" )
402439 o .ReadTimeout = q .duration ("read_timeout" )
403440 o .WriteTimeout = q .duration ("write_timeout" )
404441 o .ContextTimeoutEnabled = q .bool ("context_timeout_enabled" )
405442 o .PoolFIFO = q .bool ("pool_fifo" )
406443 o .PoolSize = q .int ("pool_size" )
444+ o .MaxConcurrentDials = q .int ("max_concurrent_dials" )
407445 o .MinIdleConns = q .int ("min_idle_conns" )
408446 o .MaxIdleConns = q .int ("max_idle_conns" )
409447 o .MaxActiveConns = q .int ("max_active_conns" )
0 commit comments