Skip to content

Commit a604ea5

Browse files
committed
fix: add unstableresp3 to cluster client (#3266)
* fix: add unstableresp3 to cluster client * propagate unstableresp3 * proper test that will ignore error, but fail if client panics * add separate test for clusterclient constructor
1 parent 2f9d902 commit a604ea5

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

options.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ type Options struct {
154154
// Add suffix to client name. Default is empty.
155155
IdentitySuffix string
156156

157-
// Enable Unstable mode for Redis Search module with RESP3.
157+
// UnstableResp3 enables Unstable mode for Redis Search module with RESP3.
158158
UnstableResp3 bool
159159
}
160160

osscluster.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ type ClusterOptions struct {
9090
DisableIndentity bool // Disable set-lib on connect. Default is false.
9191

9292
IdentitySuffix string // Add suffix to client name. Default is empty.
93+
94+
// UnstableResp3 enables Unstable mode for Redis Search module with RESP3.
95+
UnstableResp3 bool
9396
}
9497

9598
func (opt *ClusterOptions) init() {
@@ -304,7 +307,8 @@ func (opt *ClusterOptions) clientOptions() *Options {
304307
// much use for ClusterSlots config). This means we cannot execute the
305308
// READONLY command against that node -- setting readOnly to false in such
306309
// situations in the options below will prevent that from happening.
307-
readOnly: opt.ReadOnly && opt.ClusterSlots == nil,
310+
readOnly: opt.ReadOnly && opt.ClusterSlots == nil,
311+
UnstableResp3: opt.UnstableResp3,
308312
}
309313
}
310314

universal.go

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func (o *UniversalOptions) Cluster() *ClusterOptions {
115115

116116
DisableIndentity: o.DisableIndentity,
117117
IdentitySuffix: o.IdentitySuffix,
118+
UnstableResp3: o.UnstableResp3,
118119
}
119120
}
120121

universal_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,26 @@ var _ = Describe("UniversalClient", func() {
3838
})
3939
Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred())
4040
})
41+
42+
It("connect to clusters with UniversalClient and UnstableResp3", Label("NonRedisEnterprise"), func() {
43+
client = redis.NewUniversalClient(&redis.UniversalOptions{
44+
Addrs: cluster.addrs(),
45+
Protocol: 3,
46+
UnstableResp3: true,
47+
})
48+
Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred())
49+
a := func() { client.FTInfo(ctx, "all").Result() }
50+
Expect(a).ToNot(Panic())
51+
})
52+
53+
It("connect to clusters with ClusterClient and UnstableResp3", Label("NonRedisEnterprise"), func() {
54+
client = redis.NewClusterClient(&redis.ClusterOptions{
55+
Addrs: cluster.addrs(),
56+
Protocol: 3,
57+
UnstableResp3: true,
58+
})
59+
Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred())
60+
a := func() { client.FTInfo(ctx, "all").Result() }
61+
Expect(a).ToNot(Panic())
62+
})
4163
})

0 commit comments

Comments
 (0)