forked from mirror/redis
refactor: remove unused context attribute from conn (#2150)
This commit is contained in:
parent
9c34c5345f
commit
092a692384
|
@ -155,7 +155,7 @@ func ExampleClient() {
|
|||
}
|
||||
|
||||
func ExampleConn() {
|
||||
conn := rdb.Conn(context.Background())
|
||||
conn := rdb.Conn()
|
||||
|
||||
err := conn.ClientSetName(ctx, "foobar").Err()
|
||||
if err != nil {
|
||||
|
|
10
redis.go
10
redis.go
|
@ -225,7 +225,7 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
|
|||
}
|
||||
|
||||
connPool := pool.NewSingleConnPool(c.connPool, cn)
|
||||
conn := newConn(ctx, c.opt, connPool)
|
||||
conn := newConn(c.opt, connPool)
|
||||
|
||||
var auth bool
|
||||
|
||||
|
@ -575,8 +575,8 @@ func (c *Client) WithTimeout(timeout time.Duration) *Client {
|
|||
return clone
|
||||
}
|
||||
|
||||
func (c *Client) Conn(ctx context.Context) *Conn {
|
||||
return newConn(ctx, c.opt, pool.NewStickyConnPool(c.connPool))
|
||||
func (c *Client) Conn() *Conn {
|
||||
return newConn(c.opt, pool.NewStickyConnPool(c.connPool))
|
||||
}
|
||||
|
||||
// Do creates a Cmd from the args and processes the cmd.
|
||||
|
@ -707,10 +707,9 @@ type conn struct {
|
|||
// for a continuous single Redis connection.
|
||||
type Conn struct {
|
||||
*conn
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
func newConn(ctx context.Context, opt *Options, connPool pool.Pooler) *Conn {
|
||||
func newConn(opt *Options, connPool pool.Pooler) *Conn {
|
||||
c := Conn{
|
||||
conn: &conn{
|
||||
baseClient: baseClient{
|
||||
|
@ -718,7 +717,6 @@ func newConn(ctx context.Context, opt *Options, connPool pool.Pooler) *Conn {
|
|||
connPool: connPool,
|
||||
},
|
||||
},
|
||||
ctx: ctx,
|
||||
}
|
||||
c.cmdable = c.Process
|
||||
c.statefulCmdable = c.Process
|
||||
|
|
|
@ -296,7 +296,7 @@ var _ = Describe("Client", func() {
|
|||
})
|
||||
|
||||
It("should Conn", func() {
|
||||
err := client.Conn(ctx).Get(ctx, "this-key-does-not-exist").Err()
|
||||
err := client.Conn().Get(ctx, "this-key-does-not-exist").Err()
|
||||
Expect(err).To(Equal(redis.Nil))
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue