Skip to content

Commit a25f6a8

Browse files
committed
fix retries
1 parent e38a670 commit a25f6a8

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

cmd/vl/main.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
import (
4-
"crypto/tls"
54
"flag"
65
"fmt"
76
"log"
@@ -75,15 +74,11 @@ func main() {
7574
}
7675

7776
matches := urlRE.FindAllString(string(file), -1)
78-
retryClient := retryablehttp.NewClient()
79-
retryClient.RetryMax = 10
80-
81-
r := retryablehttp.NewClient()
82-
client := r.StandardClient()
83-
client.Timeout = *timeout
84-
client.Transport = &http.Transport{
85-
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
86-
}
77+
client := retryablehttp.NewClient()
78+
client.RetryMax = 10
79+
client.RetryWaitMax = 10 * time.Second
80+
client.HTTPClient.Timeout = *timeout
81+
client.Logger = nil
8782

8883
results := make(chan *response)
8984

@@ -142,7 +137,7 @@ func main() {
142137
}
143138
}
144139

145-
func newRequest(url string) (*http.Request, error) {
140+
func newRequest(url string) (*retryablehttp.Request, error) {
146141
userAgents := []string{
147142
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15",
148143
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0",
@@ -151,7 +146,7 @@ func newRequest(url string) (*http.Request, error) {
151146
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36",
152147
}
153148

154-
req, err := http.NewRequest("GET", url, nil)
149+
req, err := retryablehttp.NewRequest("GET", url, nil)
155150
if err != nil {
156151
return nil, err
157152
}
@@ -163,7 +158,7 @@ func newRequest(url string) (*http.Request, error) {
163158
return req, err
164159
}
165160

166-
func worker(url string, results chan<- *response, client *http.Client) {
161+
func worker(url string, results chan<- *response, client *retryablehttp.Client) {
167162
var err error
168163

169164
response := &response{

0 commit comments

Comments
 (0)