Skip to content

Commit 1a902b8

Browse files
trend-shino-wuofekshenawa
authored andcommitted
Fix hard code of failing timeout
1. if not set failing time limit, default is 15 seconds.
1 parent 94cfffa commit 1a902b8

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

options.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,14 @@ type Options struct {
228228
// IdentitySuffix - add suffix to client name.
229229
IdentitySuffix string
230230

231+
<<<<<<< HEAD
231232
// UnstableResp3 enables Unstable mode for Redis Search module with RESP3.
232233
// When unstable mode is enabled, the client will use RESP3 protocol and only be able to use RawResult
233234
UnstableResp3 bool
235+
=======
236+
// Failing time limit for a node. Default is 15 seconds.
237+
FailingTimeLimit int
238+
>>>>>>> 5ee5089 (Fix hard code of failing timeout)
234239
}
235240

236241
func (opt *Options) init() {

osscluster.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ type ClusterOptions struct {
124124

125125
// UnstableResp3 enables Unstable mode for Redis Search module with RESP3.
126126
UnstableResp3 bool
127+
128+
FailingTimeLimit int // Failing time limit for a node. Default is 15 seconds.
127129
}
128130

129131
func (opt *ClusterOptions) init() {
@@ -180,6 +182,10 @@ func (opt *ClusterOptions) init() {
180182
if opt.NewClient == nil {
181183
opt.NewClient = NewClient
182184
}
185+
186+
if opt.FailingTimeLimit == 0 {
187+
opt.FailingTimeLimit = 15
188+
}
183189
}
184190

185191
// 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
284290
o.PoolTimeout = q.duration("pool_timeout")
285291
o.ConnMaxLifetime = q.duration("conn_max_lifetime")
286292
o.ConnMaxIdleTime = q.duration("conn_max_idle_time")
293+
o.FailingTimeLimit = q.int("failing_time_limit")
287294

288295
if q.err != nil {
289296
return nil, q.err
@@ -343,6 +350,7 @@ func (opt *ClusterOptions) clientOptions() *Options {
343350
DisableIdentity: opt.DisableIdentity,
344351
DisableIndentity: opt.DisableIdentity,
345352
IdentitySuffix: opt.IdentitySuffix,
353+
FailingTimeLimit: opt.FailingTimeLimit,
346354
TLSConfig: opt.TLSConfig,
347355
// If ClusterSlots is populated, then we probably have an artificial
348356
// cluster whose nodes are not in clustering mode (otherwise there isn't
@@ -432,7 +440,7 @@ func (n *clusterNode) MarkAsFailing() {
432440
}
433441

434442
func (n *clusterNode) Failing() bool {
435-
const timeout = 15 // 15 seconds
443+
timeout := int64(n.Client.opt.FailingTimeLimit)
436444

437445
failing := atomic.LoadUint32(&n.failing)
438446
if failing == 0 {

0 commit comments

Comments
 (0)