Add new reaper client with retry round tripper
@@ -5,8 +5,10 @@ import (
"encoding/json"
"errors"
"net/http"
+ "time"
"code.cloudfoundry.org/lager"
+ "github.com/concourse/retryhttp"
"github.com/concourse/worker/reaper/api"
"github.com/tedsuo/rata"
)
@@ -28,6 +30,20 @@ func NewClient(apiURL string, logger lager.Logger) ReaperClient {
}
}
+func New(apiURL string, nestedRoundTripper http.RoundTripper, logger lager.Logger) ReaperClient {
+ return &client{
+ requestGenerator: rata.NewRequestGenerator(apiURL, api.Routes),
+ httpClient: &http.Client{
+ Transport: &retryhttp.RetryRoundTripper{
+ Logger: logger.Session("retry-round-tripper"),
+ BackOffFactory: retryhttp.NewExponentialBackOffFactory(60 * time.Minute),
+ RoundTripper: nestedRoundTripper,
+ Retryer: &retryhttp.DefaultRetryer{},
+ },
+ },
+ }
+}
+
// NewWithHttpClient provides a ReaperClient based on provided URL and http.Client
func NewWithHttpClient(apiURL string, logger lager.Logger, httpClient *http.Client) ReaperClient {
return &client{
