Skip to content

Commit

Permalink
add http client timeouts configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
imjaroiswebdev committed Jan 24, 2024
1 parent 7f173ac commit f35febd
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pagerduty/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package pagerduty
import (
"fmt"
"log"
"net"
"net/http"
"runtime"
"sync"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
"github.com/heimweh/go-pagerduty/pagerduty"
Expand Down Expand Up @@ -70,7 +73,18 @@ func (c *Config) Client() (*pagerduty.Client, error) {

var httpClient *http.Client
httpClient = http.DefaultClient
httpClient.Transport = logging.NewTransport("PagerDuty", http.DefaultTransport)
httpClient.Transport = logging.NewTransport(
"PagerDuty",
&http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).DialContext,
IdleConnTimeout: 60 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
MaxIdleConnsPerHost: runtime.GOMAXPROCS(0) + 1,
})

var apiUrl = c.ApiUrl
if c.ApiUrlOverride != "" {
Expand Down

0 comments on commit f35febd

Please sign in to comment.