From 8992b255cb3befacc984af62c5d481e5cbae1b74 Mon Sep 17 00:00:00 2001 From: yuanchong Date: Thu, 8 Jun 2017 17:06:45 +0800 Subject: [PATCH 1/2] fix query nsqlookup cannot config dail timeout issue --- api_request.go | 4 ++-- consumer.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api_request.go b/api_request.go index d4e389c9..cbcb8928 100644 --- a/api_request.go +++ b/api_request.go @@ -46,8 +46,8 @@ type wrappedResp struct { } // stores the result in the value pointed to by ret(must be a pointer) -func apiRequestNegotiateV1(method string, endpoint string, body io.Reader, ret interface{}) error { - httpclient := &http.Client{Transport: newDeadlineTransport(2 * time.Second)} +func apiRequestNegotiateV1(method string, endpoint string, body io.Reader, timeout time.Duration, ret interface{}) error { + httpclient := &http.Client{Transport: newDeadlineTransport(timeout * time.Second)} req, err := http.NewRequest(method, endpoint, body) if err != nil { return err diff --git a/consumer.go b/consumer.go index 78d64941..15d65749 100644 --- a/consumer.go +++ b/consumer.go @@ -462,7 +462,7 @@ retry: r.log(LogLevelInfo, "querying nsqlookupd %s", endpoint) var data lookupResp - err := apiRequestNegotiateV1("GET", endpoint, nil, &data) + err := apiRequestNegotiateV1("GET", endpoint, nil, r.config.DialTimeout, &data) if err != nil { r.log(LogLevelError, "error querying nsqlookupd (%s) - %s", endpoint, err) retries++ From fce7ac31b5cc53c7190ba37c1bce9289c46a6e56 Mon Sep 17 00:00:00 2001 From: yuanchong Date: Thu, 8 Jun 2017 17:10:29 +0800 Subject: [PATCH 2/2] del dup time.Duration --- api_request.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_request.go b/api_request.go index cbcb8928..6ceff59b 100644 --- a/api_request.go +++ b/api_request.go @@ -47,7 +47,7 @@ type wrappedResp struct { // stores the result in the value pointed to by ret(must be a pointer) func apiRequestNegotiateV1(method string, endpoint string, body io.Reader, timeout time.Duration, ret interface{}) error { - httpclient := &http.Client{Transport: newDeadlineTransport(timeout * time.Second)} + httpclient := &http.Client{Transport: newDeadlineTransport(timeout)} req, err := http.NewRequest(method, endpoint, body) if err != nil { return err