Skip to content

chore: remove a redundant method from Ring, Client and ClusterClient #3401

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

Open
wants to merge 2 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
7 changes: 0 additions & 7 deletions osscluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,13 +979,6 @@ func (c *ClusterClient) Close() error {
return c.nodes.Close()
}

// Do create a Cmd from the args and processes the cmd.
func (c *ClusterClient) Do(ctx context.Context, args ...interface{}) *Cmd {
cmd := NewCmd(ctx, args...)
_ = c.Process(ctx, cmd)
return cmd
}

func (c *ClusterClient) Process(ctx context.Context, cmd Cmder) error {
err := c.processHook(ctx, cmd)
cmd.SetErr(err)
Expand Down
6 changes: 6 additions & 0 deletions osscluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ var _ = Describe("ClusterClient", func() {
var client *redis.ClusterClient

assertClusterClient := func() {
It("do", func() {
val, err := client.Do(ctx, "ping").Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal("PONG"))
})

It("should GET/SET/DEL", func() {
err := client.Get(ctx, "A").Err()
Expect(err).To(Equal(redis.Nil))
Expand Down
7 changes: 0 additions & 7 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,13 +776,6 @@ func (c *Client) Conn() *Conn {
return newConn(c.opt, pool.NewStickyConnPool(c.connPool), &c.hooksMixin)
}

// Do create a Cmd from the args and processes the cmd.
func (c *Client) Do(ctx context.Context, args ...interface{}) *Cmd {
cmd := NewCmd(ctx, args...)
_ = c.Process(ctx, cmd)
return cmd
}

func (c *Client) Process(ctx context.Context, cmd Cmder) error {
err := c.processHook(ctx, cmd)
cmd.SetErr(err)
Expand Down
6 changes: 6 additions & 0 deletions redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ var _ = Describe("Client", func() {
Expect(err).NotTo(HaveOccurred())
})

It("do", func() {
val, err := client.Do(ctx, "ping").Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal("PONG"))
})

It("should ping", func() {
val, err := client.Ping(ctx).Result()
Expect(err).NotTo(HaveOccurred())
Expand Down
7 changes: 0 additions & 7 deletions ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,13 +563,6 @@ func (c *Ring) SetAddrs(addrs map[string]string) {
c.sharding.SetAddrs(addrs)
}

// Do create a Cmd from the args and processes the cmd.
func (c *Ring) Do(ctx context.Context, args ...interface{}) *Cmd {
cmd := NewCmd(ctx, args...)
_ = c.Process(ctx, cmd)
return cmd
}

func (c *Ring) Process(ctx context.Context, cmd Cmder) error {
err := c.processHook(ctx, cmd)
cmd.SetErr(err)
Expand Down
6 changes: 6 additions & 0 deletions ring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ var _ = Describe("Redis Ring", func() {
Expect(ring.Close()).NotTo(HaveOccurred())
})

It("do", func() {
val, err := ring.Do(ctx, "ping").Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal("PONG"))
})

It("supports context", func() {
ctx, cancel := context.WithCancel(ctx)
cancel()
Expand Down
Loading