Skip to content

Commit

Permalink
Move Select to stateful commands and make it available only via Pipel…
Browse files Browse the repository at this point in the history
…ine and Tx.
  • Loading branch information
vmihailenco committed Jun 5, 2016
1 parent 5a2dda6 commit ac162eb
Show file tree
Hide file tree
Showing 13 changed files with 483 additions and 487 deletions.
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

0 comments on commit ac162eb

Please sign in to comment.