@@ -17,7 +17,10 @@ import (
17
17
18
18
var batchSize = 500
19
19
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
21
24
backoffs := make ([]time.Duration , count )
22
25
backoffs [0 ] = initialBackoff
23
26
for i := 1 ; i < count ; i ++ {
@@ -46,11 +49,6 @@ func ShouldRetry(request *http.Request, response *http.Response, withDelay time.
46
49
return false
47
50
}
48
51
49
- // retry settings
50
- var retrycount = 5
51
- var initialBackoff = 1 * time .Second
52
- var retryConfig = ElasticRetries (initialBackoff , retrycount )
53
-
54
52
// CreateNewIndex creates a new index for the passed in alias.
55
53
//
56
54
// 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 {
167
165
func MakeJSONRequest (method string , url string , body string , jsonStruct interface {}) (* http.Response , error ) {
168
166
req , _ := http .NewRequest (method , url , bytes .NewReader ([]byte (body )))
169
167
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 )
174
169
175
170
l := log .WithField ("url" , url ).WithField ("method" , method ).WithField ("request" , body )
176
171
if err != nil {
0 commit comments