Merge pull request #1259 from go-redis/fix/unexport-lock-clone

Unexport Clone and Lock from embedded hooks
This commit is contained in:
Vladimir Mihailenco 2020-02-12 13:44:55 +02:00 committed by GitHub
commit 709e543f16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View File

@ -696,7 +696,7 @@ func (c *ClusterClient) WithContext(ctx context.Context) *ClusterClient {
} }
clone := *c clone := *c
clone.cmdable = clone.Process clone.cmdable = clone.Process
clone.hooks.Lock() clone.hooks.lock()
clone.ctx = ctx clone.ctx = ctx
return &clone return &clone
} }

View File

@ -32,13 +32,13 @@ type hooks struct {
hooks []Hook hooks []Hook
} }
func (hs *hooks) Lock() { func (hs *hooks) lock() {
hs.hooks = hs.hooks[:len(hs.hooks):len(hs.hooks)] hs.hooks = hs.hooks[:len(hs.hooks):len(hs.hooks)]
} }
func (hs hooks) Clone() hooks { func (hs hooks) clone() hooks {
clone := hs clone := hs
clone.Lock() clone.lock()
return clone return clone
} }
@ -526,7 +526,7 @@ func NewClient(opt *Options) *Client {
func (c *Client) clone() *Client { func (c *Client) clone() *Client {
clone := *c clone := *c
clone.cmdable = clone.Process clone.cmdable = clone.Process
clone.hooks.Lock() clone.hooks.lock()
return &clone return &clone
} }

View File

@ -407,7 +407,7 @@ func (c *Ring) WithContext(ctx context.Context) *Ring {
} }
clone := *c clone := *c
clone.cmdable = clone.Process clone.cmdable = clone.Process
clone.hooks.Lock() clone.hooks.lock()
clone.ctx = ctx clone.ctx = ctx
return &clone return &clone
} }

4
tx.go
View File

@ -28,7 +28,7 @@ func (c *Client) newTx(ctx context.Context) *Tx {
opt: c.opt, opt: c.opt,
connPool: pool.NewStickyConnPool(c.connPool.(*pool.ConnPool), true), connPool: pool.NewStickyConnPool(c.connPool.(*pool.ConnPool), true),
}, },
hooks: c.hooks.Clone(), hooks: c.hooks.clone(),
ctx: ctx, ctx: ctx,
} }
tx.init() tx.init()
@ -50,7 +50,7 @@ func (c *Tx) WithContext(ctx context.Context) *Tx {
} }
clone := *c clone := *c
clone.init() clone.init()
clone.hooks.Lock() clone.hooks.lock()
clone.ctx = ctx clone.ctx = ctx
return &clone return &clone
} }