Skip to content

Commit 7575c17

Browse files
committed
add comment
1 parent 31ba855 commit 7575c17

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

redis.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ func (c *Client) WithTimeout(timeout time.Duration) *Client {
627627
clone := *c
628628
clone.baseClient = c.baseClient.withTimeout(timeout)
629629
clone.init()
630+
clone.connPool = newConnPool(clone.baseClient.opt, clone.dialHook)
630631
return &clone
631632
}
632633

redis_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,23 @@ var _ = Describe("Client", func() {
8585

8686
err = client.Ping(ctx).Err()
8787
Expect(err).NotTo(HaveOccurred())
88+
89+
//check withTimeout supports the addition of dialHook
90+
var res []string
91+
client.AddHook(&hook{
92+
dialHook: func(hook redis.DialHook) redis.DialHook {
93+
return func(ctx context.Context, network, addr string) (n net.Conn, e error) {
94+
res = append(res, "dial-hook-start")
95+
n, e = hook(ctx, network, addr)
96+
return
97+
}
98+
},
99+
})
100+
err = client.Ping(ctx).Err()
101+
Expect(err).NotTo(HaveOccurred())
102+
Expect(res).To(Equal([]string{
103+
"dial-hook-start",
104+
}))
88105
})
89106

90107
It("should ping", func() {

0 commit comments

Comments
 (0)