@@ -124,6 +124,8 @@ type ClusterOptions struct {
124
124
125
125
// UnstableResp3 enables Unstable mode for Redis Search module with RESP3.
126
126
UnstableResp3 bool
127
+
128
+ FailingTimeLimit int // Failing time limit for a node. Default is 15 seconds.
127
129
}
128
130
129
131
func (opt * ClusterOptions ) init () {
@@ -180,6 +182,10 @@ func (opt *ClusterOptions) init() {
180
182
if opt .NewClient == nil {
181
183
opt .NewClient = NewClient
182
184
}
185
+
186
+ if opt .FailingTimeLimit == 0 {
187
+ opt .FailingTimeLimit = 15
188
+ }
183
189
}
184
190
185
191
// ParseClusterURL parses a URL into ClusterOptions that can be used to connect to Redis.
@@ -284,6 +290,7 @@ func setupClusterQueryParams(u *url.URL, o *ClusterOptions) (*ClusterOptions, er
284
290
o .PoolTimeout = q .duration ("pool_timeout" )
285
291
o .ConnMaxLifetime = q .duration ("conn_max_lifetime" )
286
292
o .ConnMaxIdleTime = q .duration ("conn_max_idle_time" )
293
+ o .FailingTimeLimit = q .int ("failing_time_limit" )
287
294
288
295
if q .err != nil {
289
296
return nil , q .err
@@ -343,6 +350,7 @@ func (opt *ClusterOptions) clientOptions() *Options {
343
350
DisableIdentity : opt .DisableIdentity ,
344
351
DisableIndentity : opt .DisableIdentity ,
345
352
IdentitySuffix : opt .IdentitySuffix ,
353
+ FailingTimeLimit : opt .FailingTimeLimit ,
346
354
TLSConfig : opt .TLSConfig ,
347
355
// If ClusterSlots is populated, then we probably have an artificial
348
356
// cluster whose nodes are not in clustering mode (otherwise there isn't
@@ -432,7 +440,7 @@ func (n *clusterNode) MarkAsFailing() {
432
440
}
433
441
434
442
func (n * clusterNode ) Failing () bool {
435
- const timeout = 15 // 15 seconds
443
+ timeout := int64 ( n . Client . opt . FailingTimeLimit )
436
444
437
445
failing := atomic .LoadUint32 (& n .failing )
438
446
if failing == 0 {
0 commit comments