Added http client 1s timeout

This commit is contained in:
Ivan Daniluk 2015-05-03 19:01:54 +03:00
parent d6ccd1cc61
commit 3905b3798e
1 changed files with 5 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"errors"
"io"
"net/http"
"time"
"github.com/antonholmquist/jason"
)
@ -19,7 +20,10 @@ type Expvar struct {
// FetchExpvar fetches expvar by http for the given addr (host:port)
func FetchExpvar(addr string) (*Expvar, error) {
e := &Expvar{&jason.Object{}}
resp, err := http.Get(addr)
client := &http.Client{
Timeout: 1 * time.Second, // TODO: make it configurable or left default?
}
resp, err := client.Get(addr)
if err != nil {
return e, err
}