Skip to content

Commit

Permalink
Merge pull request #65 from appoptics/reuse-http-client
Browse files Browse the repository at this point in the history
Reuse a single http.Client instance
  • Loading branch information
Alex Kahn authored Oct 17, 2019
2 parents bf7920a + e04626e commit 43836a3
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ var (
regexpIllegalNameChars = regexp.MustCompile("[^A-Za-z0-9.:_-]") // from https://www.AppOptics.com/docs/api/#measurements
// ErrBadStatus is returned if the AppOptics API returns a non-200 error code.
ErrBadStatus = errors.New("Received non-OK status from AppOptics POST")
client = &http.Client{
Timeout: 30 * time.Second,
}
)

// ServiceAccessor defines an interface for talking to via domain-specific service constructs
Expand Down Expand Up @@ -105,13 +108,7 @@ func NewClient(token string, opts ...func(*Client) error) *Client {
c := &Client{
token: token,
baseURL: baseURL,
httpClient: &http.Client{
Timeout: 30 * time.Second,
Transport: &http.Transport{
MaxIdleConnsPerHost: 4,
IdleConnTimeout: 30 * time.Second,
},
},
httpClient: client,
}

c.alertsService = NewAlertsService(c)
Expand Down

0 comments on commit 43836a3

Please sign in to comment.