mirror of https://github.com/go-redis/redis.git
Merge pull request #1259 from go-redis/fix/unexport-lock-clone
Unexport Clone and Lock from embedded hooks
This commit is contained in:
commit
709e543f16
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
8
redis.go
8
redis.go
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
ring.go
2
ring.go
|
@ -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
4
tx.go
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue