@@ -17,10 +17,16 @@ import (
17
17
18
18
var batchSize = 500
19
19
20
- func ElasticRetries () * httpx.RetryConfig {
21
- // retry settings
22
- count := 5
23
- initialBackoff := 1 * time .Second
20
+ var retryConfig * httpx.RetryConfig
21
+
22
+ func init () {
23
+ //setup httpx retry configuration
24
+ var retrycount = 5
25
+ var initialBackoff = 1 * time .Second
26
+ retryConfig = ElasticRetries (initialBackoff , retrycount )
27
+ }
28
+
29
+ func ElasticRetries (initialBackoff time.Duration , count int ) * httpx.RetryConfig {
24
30
backoffs := make ([]time.Duration , count )
25
31
backoffs [0 ] = initialBackoff
26
32
for i := 1 ; i < count ; i ++ {
@@ -165,7 +171,7 @@ func CleanupIndexes(url string, alias string) error {
165
171
func MakeJSONRequest (method string , url string , body string , jsonStruct interface {}) (* http.Response , error ) {
166
172
req , _ := http .NewRequest (method , url , bytes .NewReader ([]byte (body )))
167
173
req .Header .Add ("Content-Type" , "application/json" )
168
- resp , err := httpx .Do (http .DefaultClient , req , ElasticRetries () , nil )
174
+ resp , err := httpx .Do (http .DefaultClient , req , retryConfig , nil )
169
175
170
176
l := log .WithField ("url" , url ).WithField ("method" , method ).WithField ("request" , body )
171
177
if err != nil {
0 commit comments