From e694ed0084918780b24b6b1196bebd25dab01a97 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Sun, 18 Aug 2019 17:03:32 +0300 Subject: [PATCH] Cleanup --- internal/pool/pool.go | 2 +- internal/pool/pool_single.go | 8 ++++---- options.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/pool/pool.go b/internal/pool/pool.go index ff946424..f32d8549 100644 --- a/internal/pool/pool.go +++ b/internal/pool/pool.go @@ -49,7 +49,7 @@ type Pooler interface { } type Options struct { - Dialer func(c context.Context) (net.Conn, error) + Dialer func(context.Context) (net.Conn, error) OnClose func(*Conn) error PoolSize int diff --git a/internal/pool/pool_single.go b/internal/pool/pool_single.go index 94743748..eaf6e0ed 100644 --- a/internal/pool/pool_single.go +++ b/internal/pool/pool_single.go @@ -58,20 +58,20 @@ func (p *SingleConnPool) SetConn(cn *Conn) { } } -func (p *SingleConnPool) NewConn(c context.Context) (*Conn, error) { - return p.pool.NewConn(c) +func (p *SingleConnPool) NewConn(ctx context.Context) (*Conn, error) { + return p.pool.NewConn(ctx) } func (p *SingleConnPool) CloseConn(cn *Conn) error { return p.pool.CloseConn(cn) } -func (p *SingleConnPool) Get(c context.Context) (*Conn, error) { +func (p *SingleConnPool) Get(ctx context.Context) (*Conn, error) { // In worst case this races with Close which is not a very common operation. for i := 0; i < 1000; i++ { switch atomic.LoadUint32(&p.state) { case stateDefault: - cn, err := p.pool.Get(c) + cn, err := p.pool.Get(ctx) if err != nil { return nil, err } diff --git a/options.go b/options.go index 47110428..d29526c7 100644 --- a/options.go +++ b/options.go @@ -215,8 +215,8 @@ func ParseURL(redisURL string) (*Options, error) { func newConnPool(opt *Options) *pool.ConnPool { return pool.NewConnPool(&pool.Options{ - Dialer: func(c context.Context) (net.Conn, error) { - return opt.Dialer(c, opt.Network, opt.Addr) + Dialer: func(ctx context.Context) (net.Conn, error) { + return opt.Dialer(ctx, opt.Network, opt.Addr) }, PoolSize: opt.PoolSize, MinIdleConns: opt.MinIdleConns,