Skip to content

Commit ac162eb

Browse files
committed
Move Select to stateful commands and make it available only via Pipeline and Tx.
1 parent 5a2dda6 commit ac162eb

File tree

13 files changed

+483
-487
lines changed

13 files changed

+483
-487
lines changed

cluster.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type clusterNode struct {
2121
// or more underlying connections. It's safe for concurrent use by
2222
// multiple goroutines.
2323
type ClusterClient struct {
24-
commandable
24+
cmdable
2525

2626
opt *ClusterOptions
2727

@@ -51,7 +51,7 @@ func NewClusterClient(opt *ClusterOptions) *ClusterClient {
5151

5252
cmdsInfoOnce: new(sync.Once),
5353
}
54-
client.commandable.process = client.process
54+
client.cmdable.process = client.Process
5555

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

245-
func (c *ClusterClient) process(cmd Cmder) {
245+
func (c *ClusterClient) Process(cmd Cmder) {
246246
var ask bool
247247
slot, node := c.cmdSlotAndNode(cmd)
248248

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

400400
func (c *ClusterClient) Pipeline() *Pipeline {
401-
pipe := &Pipeline{
401+
pipe := Pipeline{
402402
exec: c.pipelineExec,
403403
}
404-
pipe.commandable.process = pipe.process
405-
return pipe
404+
pipe.cmdable.process = pipe.Process
405+
pipe.statefulCmdable.process = pipe.Process
406+
return &pipe
406407
}
407408

408409
func (c *ClusterClient) Pipelined(fn func(*Pipeline) error) ([]Cmder, error) {

cluster_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,17 @@ var _ = Describe("Cluster", func() {
300300
Expect(nodesList).Should(HaveLen(1))
301301
})
302302

303-
It("should CLUSTER READONLY", func() {
304-
res, err := cluster.primary().ReadOnly().Result()
305-
Expect(err).NotTo(HaveOccurred())
306-
Expect(res).To(Equal("OK"))
307-
})
308-
309-
It("should CLUSTER READWRITE", func() {
310-
res, err := cluster.primary().ReadWrite().Result()
311-
Expect(err).NotTo(HaveOccurred())
312-
Expect(res).To(Equal("OK"))
313-
})
303+
// It("should CLUSTER READONLY", func() {
304+
// res, err := cluster.primary().ReadOnly().Result()
305+
// Expect(err).NotTo(HaveOccurred())
306+
// Expect(res).To(Equal("OK"))
307+
// })
308+
309+
// It("should CLUSTER READWRITE", func() {
310+
// res, err := cluster.primary().ReadWrite().Result()
311+
// Expect(err).NotTo(HaveOccurred())
312+
// Expect(res).To(Equal("OK"))
313+
// })
314314
})
315315

316316
Describe("Client", func() {

0 commit comments

Comments
 (0)