Skip to content

Commit 092a692

Browse files
authored
refactor: remove unused context attribute from conn (#2150)
1 parent 9c34c53 commit 092a692

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func ExampleClient() {
155155
}
156156

157157
func ExampleConn() {
158-
conn := rdb.Conn(context.Background())
158+
conn := rdb.Conn()
159159

160160
err := conn.ClientSetName(ctx, "foobar").Err()
161161
if err != nil {

redis.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
225225
}
226226

227227
connPool := pool.NewSingleConnPool(c.connPool, cn)
228-
conn := newConn(ctx, c.opt, connPool)
228+
conn := newConn(c.opt, connPool)
229229

230230
var auth bool
231231

@@ -575,8 +575,8 @@ func (c *Client) WithTimeout(timeout time.Duration) *Client {
575575
return clone
576576
}
577577

578-
func (c *Client) Conn(ctx context.Context) *Conn {
579-
return newConn(ctx, c.opt, pool.NewStickyConnPool(c.connPool))
578+
func (c *Client) Conn() *Conn {
579+
return newConn(c.opt, pool.NewStickyConnPool(c.connPool))
580580
}
581581

582582
// Do creates a Cmd from the args and processes the cmd.
@@ -707,18 +707,16 @@ type conn struct {
707707
// for a continuous single Redis connection.
708708
type Conn struct {
709709
*conn
710-
ctx context.Context
711710
}
712711

713-
func newConn(ctx context.Context, opt *Options, connPool pool.Pooler) *Conn {
712+
func newConn(opt *Options, connPool pool.Pooler) *Conn {
714713
c := Conn{
715714
conn: &conn{
716715
baseClient: baseClient{
717716
opt: opt,
718717
connPool: connPool,
719718
},
720719
},
721-
ctx: ctx,
722720
}
723721
c.cmdable = c.Process
724722
c.statefulCmdable = c.Process

redis_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ var _ = Describe("Client", func() {
296296
})
297297

298298
It("should Conn", func() {
299-
err := client.Conn(ctx).Get(ctx, "this-key-does-not-exist").Err()
299+
err := client.Conn().Get(ctx, "this-key-does-not-exist").Err()
300300
Expect(err).To(Equal(redis.Nil))
301301
})
302302

0 commit comments

Comments
 (0)