Skip to content

Commit e2855ea

Browse files
committed
cleanup retry variables
1 parent 797e815 commit e2855ea

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

indexer.go

+5-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import (
1717

1818
var batchSize = 500
1919

20-
func ElasticRetries(initialBackoff time.Duration, count int) *httpx.RetryConfig {
20+
func ElasticRetries() *httpx.RetryConfig {
21+
// retry settings
22+
count := 5
23+
initialBackoff := 1 * time.Second
2124
backoffs := make([]time.Duration, count)
2225
backoffs[0] = initialBackoff
2326
for i := 1; i < count; i++ {
@@ -46,11 +49,6 @@ func ShouldRetry(request *http.Request, response *http.Response, withDelay time.
4649
return false
4750
}
4851

49-
// retry settings
50-
var retrycount = 5
51-
var initialBackoff = 1 * time.Second
52-
var retryConfig = ElasticRetries(initialBackoff, retrycount)
53-
5452
// CreateNewIndex creates a new index for the passed in alias.
5553
//
5654
// 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 {
167165
func MakeJSONRequest(method string, url string, body string, jsonStruct interface{}) (*http.Response, error) {
168166
req, _ := http.NewRequest(method, url, bytes.NewReader([]byte(body)))
169167
req.Header.Add("Content-Type", "application/json")
170-
retrycount := 5
171-
initialBackoff := 2 * time.Second
172-
retryConfig := ElasticRetries(initialBackoff, retrycount)
173-
resp, err := httpx.Do(http.DefaultClient, req, retryConfig, nil)
168+
resp, err := httpx.Do(http.DefaultClient, req, ElasticRetries(), nil)
174169

175170
l := log.WithField("url", url).WithField("method", method).WithField("request", body)
176171
if err != nil {

0 commit comments

Comments
 (0)