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

Move Select to stateful commands and make it available only via Pipel… #326

Merged
merged 1 commit into from
Jun 5, 2016
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
13 changes: 7 additions & 6 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type clusterNode struct {
// or more underlying connections. It's safe for concurrent use by
// multiple goroutines.
type ClusterClient struct {
commandable
cmdable

opt *ClusterOptions

Expand Down Expand Up @@ -51,7 +51,7 @@ func NewClusterClient(opt *ClusterOptions) *ClusterClient {

cmdsInfoOnce: new(sync.Once),
}
client.commandable.process = client.process
client.cmdable.process = client.Process

for _, addr := range opt.Addrs {
_ = client.nodeByAddr(addr)
Expand Down Expand Up @@ -242,7 +242,7 @@ func (c *ClusterClient) cmdSlotAndNode(cmd Cmder) (int, *clusterNode) {
return slot, c.slotMasterNode(slot)
}

func (c *ClusterClient) process(cmd Cmder) {
func (c *ClusterClient) Process(cmd Cmder) {
var ask bool
slot, node := c.cmdSlotAndNode(cmd)

Expand Down Expand Up @@ -398,11 +398,12 @@ func (c *ClusterClient) reaper(frequency time.Duration) {
}

func (c *ClusterClient) Pipeline() *Pipeline {
pipe := &Pipeline{
pipe := Pipeline{
exec: c.pipelineExec,
}
pipe.commandable.process = pipe.process
return pipe
pipe.cmdable.process = pipe.Process
pipe.statefulCmdable.process = pipe.Process
return &pipe
}

func (c *ClusterClient) Pipelined(fn func(*Pipeline) error) ([]Cmder, error) {
Expand Down
22 changes: 11 additions & 11 deletions cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,17 +300,17 @@ var _ = Describe("Cluster", func() {
Expect(nodesList).Should(HaveLen(1))
})

It("should CLUSTER READONLY", func() {
res, err := cluster.primary().ReadOnly().Result()
Expect(err).NotTo(HaveOccurred())
Expect(res).To(Equal("OK"))
})

It("should CLUSTER READWRITE", func() {
res, err := cluster.primary().ReadWrite().Result()
Expect(err).NotTo(HaveOccurred())
Expect(res).To(Equal("OK"))
})
// It("should CLUSTER READONLY", func() {
// res, err := cluster.primary().ReadOnly().Result()
// Expect(err).NotTo(HaveOccurred())
// Expect(res).To(Equal("OK"))
// })

// It("should CLUSTER READWRITE", func() {
// res, err := cluster.primary().ReadWrite().Result()
// Expect(err).NotTo(HaveOccurred())
// Expect(res).To(Equal("OK"))
// })
})

Describe("Client", func() {
Expand Down
Loading