diff --git a/indexer.go b/indexer.go index e1507cc..3ce122f 100644 --- a/indexer.go +++ b/indexer.go @@ -17,7 +17,10 @@ import ( var batchSize = 500 -func ElasticRetries(initialBackoff time.Duration, count int) *httpx.RetryConfig { +func ElasticRetries() *httpx.RetryConfig { + // retry settings + count := 5 + initialBackoff := 1 * time.Second backoffs := make([]time.Duration, count) backoffs[0] = initialBackoff for i := 1; i < count; i++ { @@ -46,11 +49,6 @@ func ShouldRetry(request *http.Request, response *http.Response, withDelay time. return false } -// retry settings -var retrycount = 5 -var initialBackoff = 1 * time.Second -var retryConfig = ElasticRetries(initialBackoff, retrycount) - // CreateNewIndex creates a new index for the passed in alias. // // Note that we do not create an index with the passed name, instead creating one @@ -167,10 +165,7 @@ func CleanupIndexes(url string, alias string) error { func MakeJSONRequest(method string, url string, body string, jsonStruct interface{}) (*http.Response, error) { req, _ := http.NewRequest(method, url, bytes.NewReader([]byte(body))) req.Header.Add("Content-Type", "application/json") - retrycount := 5 - initialBackoff := 2 * time.Second - retryConfig := ElasticRetries(initialBackoff, retrycount) - resp, err := httpx.Do(http.DefaultClient, req, retryConfig, nil) + resp, err := httpx.Do(http.DefaultClient, req, ElasticRetries(), nil) l := log.WithField("url", url).WithField("method", method).WithField("request", body) if err != nil {