diff --git a/redis.go b/redis.go index cae12f8c9..49c8ccca8 100644 --- a/redis.go +++ b/redis.go @@ -627,6 +627,7 @@ func (c *Client) WithTimeout(timeout time.Duration) *Client { clone := *c clone.baseClient = c.baseClient.withTimeout(timeout) clone.init() + clone.connPool = newConnPool(clone.baseClient.opt, clone.dialHook) return &clone } diff --git a/redis_test.go b/redis_test.go index 92b24c729..93f3c7050 100644 --- a/redis_test.go +++ b/redis_test.go @@ -85,6 +85,23 @@ var _ = Describe("Client", func() { err = client.Ping(ctx).Err() Expect(err).NotTo(HaveOccurred()) + + //check withTimeout supports the addition of dialHook + var res []string + client.AddHook(&hook{ + dialHook: func(hook redis.DialHook) redis.DialHook { + return func(ctx context.Context, network, addr string) (n net.Conn, e error) { + res = append(res, "dial-hook-start") + n, e = hook(ctx, network, addr) + return + } + }, + }) + err = client.Ping(ctx).Err() + Expect(err).NotTo(HaveOccurred()) + Expect(res).To(Equal([]string{ + "dial-hook-start", + })) }) It("should ping", func() {