Skip to content

fix: add unstableresp3 to cluster client #3266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 5 additions & 1 deletion osscluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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,
}
}

Expand Down
1 change: 1 addition & 0 deletions universal.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func (o *UniversalOptions) Cluster() *ClusterOptions {

DisableIndentity: o.DisableIndentity,
IdentitySuffix: o.IdentitySuffix,
UnstableResp3: o.UnstableResp3,
}
}

Expand Down
22 changes: 22 additions & 0 deletions universal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
})
Loading