Skip to content

Commit

Permalink
Merge pull request redis#1259 from go-redis/fix/unexport-lock-clone
Browse files Browse the repository at this point in the history
Unexport Clone and Lock from embedded hooks
  • Loading branch information
vmihailenco authored Feb 12, 2020
2 parents 6bd8d9c + 512e6c7 commit 709e543
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ func (c *ClusterClient) WithContext(ctx context.Context) *ClusterClient {
}
clone := *c
clone.cmdable = clone.Process
clone.hooks.Lock()
clone.hooks.lock()
clone.ctx = ctx
return &clone
}
Expand Down
8 changes: 4 additions & 4 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ type hooks struct {
hooks []Hook
}

func (hs *hooks) Lock() {
func (hs *hooks) lock() {
hs.hooks = hs.hooks[:len(hs.hooks):len(hs.hooks)]
}

func (hs hooks) Clone() hooks {
func (hs hooks) clone() hooks {
clone := hs
clone.Lock()
clone.lock()
return clone
}

Expand Down Expand Up @@ -526,7 +526,7 @@ func NewClient(opt *Options) *Client {
func (c *Client) clone() *Client {
clone := *c
clone.cmdable = clone.Process
clone.hooks.Lock()
clone.hooks.lock()
return &clone
}

Expand Down
2 changes: 1 addition & 1 deletion ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func (c *Ring) WithContext(ctx context.Context) *Ring {
}
clone := *c
clone.cmdable = clone.Process
clone.hooks.Lock()
clone.hooks.lock()
clone.ctx = ctx
return &clone
}
Expand Down
4 changes: 2 additions & 2 deletions tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (c *Client) newTx(ctx context.Context) *Tx {
opt: c.opt,
connPool: pool.NewStickyConnPool(c.connPool.(*pool.ConnPool), true),
},
hooks: c.hooks.Clone(),
hooks: c.hooks.clone(),
ctx: ctx,
}
tx.init()
Expand All @@ -50,7 +50,7 @@ func (c *Tx) WithContext(ctx context.Context) *Tx {
}
clone := *c
clone.init()
clone.hooks.Lock()
clone.hooks.lock()
clone.ctx = ctx
return &clone
}
Expand Down

0 comments on commit 709e543

Please sign in to comment.