From d0f921357d9751a3e11221a7abd072546ac67654 Mon Sep 17 00:00:00 2001 From: Nedyalko Dyakov Date: Fri, 7 Feb 2025 12:09:49 +0200 Subject: [PATCH] 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 --- options.go | 2 +- osscluster.go | 6 +++++- universal.go | 1 + universal_test.go | 22 ++++++++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/options.go b/options.go index b9701702..a350a02f 100644 --- a/options.go +++ b/options.go @@ -154,7 +154,7 @@ type Options struct { // Add suffix to client name. Default is empty. IdentitySuffix string - // Enable Unstable mode for Redis Search module with RESP3. + // UnstableResp3 enables Unstable mode for Redis Search module with RESP3. UnstableResp3 bool } diff --git a/osscluster.go b/osscluster.go index 188f5035..517fbd45 100644 --- a/osscluster.go +++ b/osscluster.go @@ -94,6 +94,9 @@ type ClusterOptions struct { DisableIndentity bool // Disable set-lib on connect. Default is false. IdentitySuffix string // Add suffix to client name. Default is empty. + + // UnstableResp3 enables Unstable mode for Redis Search module with RESP3. + UnstableResp3 bool } func (opt *ClusterOptions) init() { @@ -308,7 +311,8 @@ func (opt *ClusterOptions) clientOptions() *Options { // much use for ClusterSlots config). This means we cannot execute the // READONLY command against that node -- setting readOnly to false in such // situations in the options below will prevent that from happening. - readOnly: opt.ReadOnly && opt.ClusterSlots == nil, + readOnly: opt.ReadOnly && opt.ClusterSlots == nil, + UnstableResp3: opt.UnstableResp3, } } diff --git a/universal.go b/universal.go index f4d2d759..47fda276 100644 --- a/universal.go +++ b/universal.go @@ -115,6 +115,7 @@ func (o *UniversalOptions) Cluster() *ClusterOptions { DisableIndentity: o.DisableIndentity, IdentitySuffix: o.IdentitySuffix, + UnstableResp3: o.UnstableResp3, } } diff --git a/universal_test.go b/universal_test.go index 747c68ac..9328b477 100644 --- a/universal_test.go +++ b/universal_test.go @@ -38,4 +38,26 @@ var _ = Describe("UniversalClient", func() { }) Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred()) }) + + It("connect to clusters with UniversalClient and UnstableResp3", Label("NonRedisEnterprise"), func() { + client = redis.NewUniversalClient(&redis.UniversalOptions{ + Addrs: cluster.addrs(), + Protocol: 3, + UnstableResp3: true, + }) + Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred()) + a := func() { client.FTInfo(ctx, "all").Result() } + Expect(a).ToNot(Panic()) + }) + + It("connect to clusters with ClusterClient and UnstableResp3", Label("NonRedisEnterprise"), func() { + client = redis.NewClusterClient(&redis.ClusterOptions{ + Addrs: cluster.addrs(), + Protocol: 3, + UnstableResp3: true, + }) + Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred()) + a := func() { client.FTInfo(ctx, "all").Result() } + Expect(a).ToNot(Panic()) + }) })