Skip to content

Commit 1b9d247

Browse files
authored
Merge branch 'master' into DOC-4231-set-tces
2 parents 971489e + 04005cb commit 1b9d247

File tree

14 files changed

+289
-9
lines changed

14 files changed

+289
-9
lines changed

.github/wordlist.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ACLs
2+
APIs
23
autoload
34
autoloader
45
autoloading
@@ -46,9 +47,11 @@ runtime
4647
SHA
4748
sharding
4849
SETNAME
50+
SpellCheck
4951
SSL
5052
struct
5153
stunnel
54+
SynDump
5255
TCP
5356
TLS
5457
uri

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ rdb := redis.NewClient(&redis.Options{
183183
})
184184
```
185185

186+
#### Unstable RESP3 Structures for RediSearch Commands
187+
When integrating Redis with application functionalities using RESP3, it's important to note that some response structures aren't final yet. This is especially true for more complex structures like search and query results. We recommend using RESP2 when using the search and query capabilities, but we plan to stabilize the RESP3-based API-s in the coming versions. You can find more guidance in the upcoming release notes.
188+
186189
## Contributing
187190

188191
Please see [out contributing guidelines](CONTRIBUTING.md) to help us improve this library!

command.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type Cmder interface {
4040

4141
readTimeout() *time.Duration
4242
readReply(rd *proto.Reader) error
43-
43+
readRawReply(rd *proto.Reader) error
4444
SetErr(error)
4545
Err() error
4646
}
@@ -122,11 +122,11 @@ func cmdString(cmd Cmder, val interface{}) string {
122122
//------------------------------------------------------------------------------
123123

124124
type baseCmd struct {
125-
ctx context.Context
126-
args []interface{}
127-
err error
128-
keyPos int8
129-
125+
ctx context.Context
126+
args []interface{}
127+
err error
128+
keyPos int8
129+
rawVal interface{}
130130
_readTimeout *time.Duration
131131
}
132132

@@ -197,6 +197,11 @@ func (cmd *baseCmd) setReadTimeout(d time.Duration) {
197197
cmd._readTimeout = &d
198198
}
199199

200+
func (cmd *baseCmd) readRawReply(rd *proto.Reader) (err error) {
201+
cmd.rawVal, err = rd.ReadReply()
202+
return err
203+
}
204+
200205
//------------------------------------------------------------------------------
201206

202207
type Cmd struct {

extra/rediscensus/go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ require (
1717
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
1818
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
1919
)
20+
21+
retract (
22+
v9.5.3 // This version was accidentally released.
23+
)

extra/rediscmd/go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ require (
1414
github.com/cespare/xxhash/v2 v2.2.0 // indirect
1515
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
1616
)
17+
18+
retract (
19+
v9.5.3 // This version was accidentally released.
20+
)

extra/redisotel/go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ require (
2222
github.com/go-logr/stdr v1.2.2 // indirect
2323
golang.org/x/sys v0.16.0 // indirect
2424
)
25+
26+
retract (
27+
v9.5.3 // This version was accidentally released.
28+
)

extra/redisprometheus/go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ require (
2121
golang.org/x/sys v0.4.0 // indirect
2222
google.golang.org/protobuf v1.33.0 // indirect
2323
)
24+
25+
retract (
26+
v9.5.3 // This version was accidentally released.
27+
)

options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ type Options struct {
153153

154154
// Add suffix to client name. Default is empty.
155155
IdentitySuffix string
156+
157+
// Enable Unstable mode for Redis Search module with RESP3.
158+
UnstableResp3 bool
156159
}
157160

158161
func (opt *Options) init() {

redis.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,19 @@ func (c *baseClient) process(ctx context.Context, cmd Cmder) error {
412412
return lastErr
413413
}
414414

415+
func (c *baseClient) assertUnstableCommand(cmd Cmder) bool {
416+
switch cmd.(type) {
417+
case *AggregateCmd, *FTInfoCmd, *FTSpellCheckCmd, *FTSearchCmd, *FTSynDumpCmd:
418+
if c.opt.UnstableResp3 {
419+
return true
420+
} else {
421+
panic("RESP3 responses for this command are disabled because they may still change. Please set the flag UnstableResp3 . See the [README](https://github.com/redis/go-redis/blob/master/README.md) and the release notes for guidance.")
422+
}
423+
default:
424+
return false
425+
}
426+
}
427+
415428
func (c *baseClient) _process(ctx context.Context, cmd Cmder, attempt int) (bool, error) {
416429
if attempt > 0 {
417430
if err := internal.Sleep(ctx, c.retryBackoff(attempt)); err != nil {
@@ -427,8 +440,12 @@ func (c *baseClient) _process(ctx context.Context, cmd Cmder, attempt int) (bool
427440
atomic.StoreUint32(&retryTimeout, 1)
428441
return err
429442
}
430-
431-
if err := cn.WithReader(c.context(ctx), c.cmdTimeout(cmd), cmd.readReply); err != nil {
443+
readReplyFunc := cmd.readReply
444+
// Apply unstable RESP3 search module.
445+
if c.opt.Protocol != 2 && c.assertUnstableCommand(cmd) {
446+
readReplyFunc = cmd.readRawReply
447+
}
448+
if err := cn.WithReader(c.context(ctx), c.cmdTimeout(cmd), readReplyFunc); err != nil {
432449
if cmd.readTimeout() == nil {
433450
atomic.StoreUint32(&retryTimeout, 1)
434451
} else {

ring.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ type RingOptions struct {
100100

101101
DisableIndentity bool
102102
IdentitySuffix string
103+
UnstableResp3 bool
103104
}
104105

105106
func (opt *RingOptions) init() {
@@ -168,6 +169,7 @@ func (opt *RingOptions) clientOptions() *Options {
168169

169170
DisableIndentity: opt.DisableIndentity,
170171
IdentitySuffix: opt.IdentitySuffix,
172+
UnstableResp3: opt.UnstableResp3,
171173
}
172174
}
173175

0 commit comments

Comments
 (0)