Skip to content

Commit

Permalink
Add UnstableResp3SearchModule check to assertStableCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
ofekshenawa committed Sep 2, 2024
1 parent 8f3373b commit ca4e352
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,18 +412,18 @@ func (c *baseClient) process(ctx context.Context, cmd Cmder) error {
return lastErr
}

func (c *baseClient) isProblematicMethodsOfSearchResp3(ctx context.Context, cmd Cmder) bool {
if c.opt.Protocol != 3 {
return false
func (c *baseClient) assertStableCommand(ctx context.Context, cmd Cmder) bool {
if c.opt.Protocol != 2 && c.opt.UnstableResp3SearchModule {
switch cmd.(type) {
case *AggregateCmd, *FTInfoCmd, *FTSpellCheckCmd, *FTSearchCmd, *FTSynDumpCmd:
internal.Logger.Printf(ctx, "Some RESP3 results for Redis Query Engine responses may change. Refer to the readme for guidance")
return true
default:
return false
}
}
return false

switch cmd.(type) {
case *AggregateCmd, *FTInfoCmd, *FTSpellCheckCmd, *FTSearchCmd, *FTSynDumpCmd:
internal.Logger.Printf(ctx, "Some RESP3 results for Redis Query Engine responses may change. Refer to the readme for guidance")
return true
default:
return false
}
}

func (c *baseClient) _process(ctx context.Context, cmd Cmder, attempt int) (bool, error) {
Expand All @@ -443,7 +443,7 @@ func (c *baseClient) _process(ctx context.Context, cmd Cmder, attempt int) (bool
}
readReplyFunc := cmd.readReply
// Apply unstable RESP3 search module.
if c.opt.UnstableResp3SearchModule && c.isProblematicMethodsOfSearchResp3(ctx, cmd) {
if c.assertStableCommand(ctx, cmd) {
readReplyFunc = cmd.readRawReply
}
if err := cn.WithReader(c.context(ctx), c.cmdTimeout(cmd), readReplyFunc); err != nil {
Expand Down

0 comments on commit ca4e352

Please sign in to comment.