Skip to content
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

add readOnly on failover opts #3281

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
Binary file added oryxBuildBinary
Binary file not shown.
2 changes: 2 additions & 0 deletions universal.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ func (o *UniversalOptions) Failover() *FailoverOptions {

TLSConfig: o.TLSConfig,

ReplicaOnly: o.ReadOnly,

DisableIndentity: o.DisableIndentity,
IdentitySuffix: o.IdentitySuffix,
UnstableResp3: o.UnstableResp3,
Expand Down
28 changes: 28 additions & 0 deletions universal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,32 @@ var _ = Describe("UniversalClient", func() {
a := func() { client.FTInfo(ctx, "all").Result() }
Expect(a).ToNot(Panic())
})


It("should connect to failover servers on slaves when readonly Options is ok", func() {
Skip("Flaky Test")
client = redis.NewUniversalClient(&redis.UniversalOptions{
MasterName: sentinelName,
Addrs: sentinelAddrs,
ReadOnly: true,
})
Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred())


roleCmd := client.Do(ctx, "ROLE")
role, err := roleCmd.Result()
Expect(err).NotTo(HaveOccurred())

roleSlice, ok := role.([]interface{})
Expect(ok).To(BeTrue())
Expect(roleSlice[0]).To(Equal("slave"))


err = client.Set(ctx, "somekey", "somevalue", 0).Err()
Expect(err).To(HaveOccurred())

})


})

Loading