From d30695a78b1bf0080c7db18515509c4ce3776bdb Mon Sep 17 00:00:00 2001 From: ofekshenawa Date: Sat, 31 Aug 2024 19:28:50 +0300 Subject: [PATCH] Add UnstableResp3SearchModule to client options --- options.go | 3 +++ redis.go | 5 +++-- ring.go | 10 ++++++---- sentinel.go | 15 +++++++++------ universal.go | 15 +++++++++------ 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/options.go b/options.go index 6ed693a0b..f7fd4c16c 100644 --- a/options.go +++ b/options.go @@ -153,6 +153,9 @@ type Options struct { // Add suffix to client name. Default is empty. IdentitySuffix string + + // Enable Unstable mode for Redis Search module with RESP3. + UnstableResp3SearchModule bool } func (opt *Options) init() { diff --git a/redis.go b/redis.go index ba14f1fca..301852839 100644 --- a/redis.go +++ b/redis.go @@ -4,7 +4,7 @@ import ( "context" "errors" "fmt" - "net" // TODO change to import only specific method (Not necesarry in compiling) + "net" "sync" "sync/atomic" "time" @@ -442,7 +442,8 @@ func (c *baseClient) _process(ctx context.Context, cmd Cmder, attempt int) (bool return err } readReplyFunc := cmd.readReply - if c.isProblematicMethodsOfSearchResp3(cmd) { + // Apply unstable RESP3 search module. + if c.opt.UnstableResp3SearchModule && c.isProblematicMethodsOfSearchResp3(cmd) { readReplyFunc = cmd.readRawReply } if err := cn.WithReader(c.context(ctx), c.cmdTimeout(cmd), readReplyFunc); err != nil { diff --git a/ring.go b/ring.go index 4ae00542b..5768e90b3 100644 --- a/ring.go +++ b/ring.go @@ -98,8 +98,9 @@ type RingOptions struct { TLSConfig *tls.Config Limiter Limiter - DisableIndentity bool - IdentitySuffix string + DisableIndentity bool + IdentitySuffix string + UnstableResp3SearchModule bool } func (opt *RingOptions) init() { @@ -166,8 +167,9 @@ func (opt *RingOptions) clientOptions() *Options { TLSConfig: opt.TLSConfig, Limiter: opt.Limiter, - DisableIndentity: opt.DisableIndentity, - IdentitySuffix: opt.IdentitySuffix, + DisableIndentity: opt.DisableIndentity, + IdentitySuffix: opt.IdentitySuffix, + UnstableResp3SearchModule: opt.UnstableResp3SearchModule, } } diff --git a/sentinel.go b/sentinel.go index 188f88494..925d76065 100644 --- a/sentinel.go +++ b/sentinel.go @@ -80,8 +80,9 @@ type FailoverOptions struct { TLSConfig *tls.Config - DisableIndentity bool - IdentitySuffix string + DisableIndentity bool + IdentitySuffix string + UnstableResp3SearchModule bool } func (opt *FailoverOptions) clientOptions() *Options { @@ -117,8 +118,9 @@ func (opt *FailoverOptions) clientOptions() *Options { TLSConfig: opt.TLSConfig, - DisableIndentity: opt.DisableIndentity, - IdentitySuffix: opt.IdentitySuffix, + DisableIndentity: opt.DisableIndentity, + IdentitySuffix: opt.IdentitySuffix, + UnstableResp3SearchModule: opt.UnstableResp3SearchModule, } } @@ -154,8 +156,9 @@ func (opt *FailoverOptions) sentinelOptions(addr string) *Options { TLSConfig: opt.TLSConfig, - DisableIndentity: opt.DisableIndentity, - IdentitySuffix: opt.IdentitySuffix, + DisableIndentity: opt.DisableIndentity, + IdentitySuffix: opt.IdentitySuffix, + UnstableResp3SearchModule: opt.UnstableResp3SearchModule, } } diff --git a/universal.go b/universal.go index 275bef3d6..eae365e5d 100644 --- a/universal.go +++ b/universal.go @@ -66,8 +66,9 @@ type UniversalOptions struct { MasterName string - DisableIndentity bool - IdentitySuffix string + DisableIndentity bool + IdentitySuffix string + UnstableResp3SearchModule bool } // Cluster returns cluster options created from the universal options. @@ -158,8 +159,9 @@ func (o *UniversalOptions) Failover() *FailoverOptions { TLSConfig: o.TLSConfig, - DisableIndentity: o.DisableIndentity, - IdentitySuffix: o.IdentitySuffix, + DisableIndentity: o.DisableIndentity, + IdentitySuffix: o.IdentitySuffix, + UnstableResp3SearchModule: o.UnstableResp3SearchModule, } } @@ -201,8 +203,9 @@ func (o *UniversalOptions) Simple() *Options { TLSConfig: o.TLSConfig, - DisableIndentity: o.DisableIndentity, - IdentitySuffix: o.IdentitySuffix, + DisableIndentity: o.DisableIndentity, + IdentitySuffix: o.IdentitySuffix, + UnstableResp3SearchModule: o.UnstableResp3SearchModule, } }