github.com/saucelabs/saucectl@v0.175.1/internal/http/client.go (about)

     1  package http
     2  
     3  import (
     4  	"net/http"
     5  	"time"
     6  
     7  	"github.com/hashicorp/go-retryablehttp"
     8  )
     9  
    10  // NewRetryableClient returns a new pre-configured instance of retryablehttp.Client.
    11  func NewRetryableClient(timeout time.Duration) *retryablehttp.Client {
    12  	return &retryablehttp.Client{
    13  		HTTPClient: &http.Client{
    14  			Timeout:   timeout,
    15  			Transport: &http.Transport{Proxy: http.ProxyFromEnvironment},
    16  		},
    17  		RetryWaitMin: 1 * time.Second,
    18  		RetryWaitMax: 30 * time.Second,
    19  		RetryMax:     3,
    20  		CheckRetry:   retryablehttp.DefaultRetryPolicy,
    21  		Backoff:      retryablehttp.DefaultBackoff,
    22  		ErrorHandler: retryablehttp.PassthroughErrorHandler,
    23  	}
    24  }