Rename flag to UnstableResp3

This commit is contained in:
vladvildanov 2024-09-12 10:35:07 +03:00
parent 7141e19e9e
commit 92ba1d7a28
6 changed files with 34 additions and 34 deletions

View File

@ -155,7 +155,7 @@ type Options struct {
IdentitySuffix string
// Enable Unstable mode for Redis Search module with RESP3.
UnstableResp3SearchModule bool
UnstableResp3 bool
}
func (opt *Options) init() {

View File

@ -415,10 +415,10 @@ func (c *baseClient) process(ctx context.Context, cmd Cmder) error {
func (c *baseClient) assertUnstableCommand(cmd Cmder) bool {
switch cmd.(type) {
case *AggregateCmd, *FTInfoCmd, *FTSpellCheckCmd, *FTSearchCmd, *FTSynDumpCmd:
if c.opt.UnstableResp3SearchModule {
if c.opt.UnstableResp3 {
return true
} else {
panic("RESP3 responses for this command are disabled because they may still change. Please set the flag UnstableResp3SearchModule . See the [README](https://github.com/redis/go-redis/blob/master/README.md) and the release notes for guidance.")
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.")
}
default:
return false

12
ring.go
View File

@ -98,9 +98,9 @@ type RingOptions struct {
TLSConfig *tls.Config
Limiter Limiter
DisableIndentity bool
IdentitySuffix string
UnstableResp3SearchModule bool
DisableIndentity bool
IdentitySuffix string
UnstableResp3 bool
}
func (opt *RingOptions) init() {
@ -167,9 +167,9 @@ func (opt *RingOptions) clientOptions() *Options {
TLSConfig: opt.TLSConfig,
Limiter: opt.Limiter,
DisableIndentity: opt.DisableIndentity,
IdentitySuffix: opt.IdentitySuffix,
UnstableResp3SearchModule: opt.UnstableResp3SearchModule,
DisableIndentity: opt.DisableIndentity,
IdentitySuffix: opt.IdentitySuffix,
UnstableResp3: opt.UnstableResp3,
}
}

View File

@ -1424,7 +1424,7 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
var client2 *redis.Client
BeforeEach(func() {
client = redis.NewClient(&redis.Options{Addr: ":6379", Protocol: 3, UnstableResp3SearchModule: true})
client = redis.NewClient(&redis.Options{Addr: ":6379", Protocol: 3, UnstableResp3: true})
client2 = redis.NewClient(&redis.Options{Addr: ":6379", Protocol: 3})
Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred())
})
@ -1456,7 +1456,7 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
Expect(results[1].(map[interface{}]interface{})["extra_attributes"].(map[interface{}]interface{})["CreatedDateTimeUTC"]).
To(Or(BeEquivalentTo("6373878785249699840"), BeEquivalentTo("6373878758592700416")))
// Test with UnstableResp3SearchModule false
// Test with UnstableResp3 false
Expect(func() {
options = &redis.FTAggregateOptions{Apply: []redis.FTAggregateApply{{Field: "@CreatedDateTimeUTC * 10", As: "CreatedDateTimeUTC"}}}
rawRes, _ := client2.FTAggregateWithArgs(ctx, "idx1", "*", options).RawResult()
@ -1484,7 +1484,7 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
flags = attributes[0].(map[interface{}]interface{})["flags"].([]interface{})
Expect(flags).To(ConsistOf("SORTABLE", "NOSTEM"))
// Test with UnstableResp3SearchModule false
// Test with UnstableResp3 false
Expect(func() {
rawResInfo, _ := client2.FTInfo(ctx, "idx1").RawResult()
rawValInfo := client2.FTInfo(ctx, "idx1").RawVal()
@ -1511,7 +1511,7 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
results := resSpellCheck.(map[interface{}]interface{})["results"].(map[interface{}]interface{})
Expect(results["impornant"].([]interface{})[0].(map[interface{}]interface{})["important"]).To(BeEquivalentTo(0.5))
// Test with UnstableResp3SearchModule false
// Test with UnstableResp3 false
Expect(func() {
rawResSpellCheck, _ := client2.FTSpellCheck(ctx, "idx1", "impornant").RawResult()
rawValSpellCheck := client2.FTSpellCheck(ctx, "idx1", "impornant").RawVal()
@ -1538,7 +1538,7 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
totalResults2 := res2.(map[interface{}]interface{})["total_results"]
Expect(totalResults2).To(BeEquivalentTo(int64(1)))
// Test with UnstableResp3SearchModule false
// Test with UnstableResp3 false
Expect(func() {
rawRes2, _ := client2.FTSearchWithArgs(ctx, "txt", "foo bar hello world", &redis.FTSearchOptions{NoContent: true}).RawResult()
rawVal2 := client2.FTSearchWithArgs(ctx, "txt", "foo bar hello world", &redis.FTSearchOptions{NoContent: true}).RawVal()
@ -1572,7 +1572,7 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
Expect(valSynDump).To(BeEquivalentTo(resSynDump))
Expect(resSynDump.(map[interface{}]interface{})["baby"]).To(BeEquivalentTo([]interface{}{"id1"}))
// Test with UnstableResp3SearchModule false
// Test with UnstableResp3 false
Expect(func() {
rawResSynDump, _ := client2.FTSynDump(ctx, "idx1").RawResult()
rawValSynDump := client2.FTSynDump(ctx, "idx1").RawVal()
@ -1593,7 +1593,7 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
Expect(err).NotTo(HaveOccurred())
Expect(res1).ToNot(BeEmpty())
// Test with UnstableResp3SearchModule false
// Test with UnstableResp3 false
Expect(func() {
res2, err := client2.FTExplain(ctx, "txt", "@f3:f3_val @f2:f2_val @f1:f1_val").Result()
Expect(err).NotTo(HaveOccurred())

View File

@ -80,9 +80,9 @@ type FailoverOptions struct {
TLSConfig *tls.Config
DisableIndentity bool
IdentitySuffix string
UnstableResp3SearchModule bool
DisableIndentity bool
IdentitySuffix string
UnstableResp3 bool
}
func (opt *FailoverOptions) clientOptions() *Options {
@ -118,9 +118,9 @@ func (opt *FailoverOptions) clientOptions() *Options {
TLSConfig: opt.TLSConfig,
DisableIndentity: opt.DisableIndentity,
IdentitySuffix: opt.IdentitySuffix,
UnstableResp3SearchModule: opt.UnstableResp3SearchModule,
DisableIndentity: opt.DisableIndentity,
IdentitySuffix: opt.IdentitySuffix,
UnstableResp3: opt.UnstableResp3,
}
}
@ -156,9 +156,9 @@ func (opt *FailoverOptions) sentinelOptions(addr string) *Options {
TLSConfig: opt.TLSConfig,
DisableIndentity: opt.DisableIndentity,
IdentitySuffix: opt.IdentitySuffix,
UnstableResp3SearchModule: opt.UnstableResp3SearchModule,
DisableIndentity: opt.DisableIndentity,
IdentitySuffix: opt.IdentitySuffix,
UnstableResp3: opt.UnstableResp3,
}
}

View File

@ -66,9 +66,9 @@ type UniversalOptions struct {
MasterName string
DisableIndentity bool
IdentitySuffix string
UnstableResp3SearchModule bool
DisableIndentity bool
IdentitySuffix string
UnstableResp3 bool
}
// Cluster returns cluster options created from the universal options.
@ -159,9 +159,9 @@ func (o *UniversalOptions) Failover() *FailoverOptions {
TLSConfig: o.TLSConfig,
DisableIndentity: o.DisableIndentity,
IdentitySuffix: o.IdentitySuffix,
UnstableResp3SearchModule: o.UnstableResp3SearchModule,
DisableIndentity: o.DisableIndentity,
IdentitySuffix: o.IdentitySuffix,
UnstableResp3: o.UnstableResp3,
}
}
@ -203,9 +203,9 @@ func (o *UniversalOptions) Simple() *Options {
TLSConfig: o.TLSConfig,
DisableIndentity: o.DisableIndentity,
IdentitySuffix: o.IdentitySuffix,
UnstableResp3SearchModule: o.UnstableResp3SearchModule,
DisableIndentity: o.DisableIndentity,
IdentitySuffix: o.IdentitySuffix,
UnstableResp3: o.UnstableResp3,
}
}