Skip to content

Commit 7ef02c2

Browse files
committed
add retry for 429
Signed-off-by: cuisongliu <[email protected]>
1 parent f796918 commit 7ef02c2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

dockerhub/http.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"bytes"
2121
"context"
2222
"fmt"
23+
"github.com/cuisongliu/logger"
2324
"io"
2425
"net"
2526
"net/http"
@@ -58,6 +59,8 @@ func Request(url, method string, requestData []byte, timeout int64) ([]byte, err
5859
}
5960
if resp.StatusCode != 200 {
6061
if resp.StatusCode == 429 {
62+
logger.Warn("request %s resp code is %d, retry after 2s", url, resp.StatusCode)
63+
time.Sleep(2 * time.Second)
6164
return Request(url, method, requestData, timeout)
6265
}
6366
return nil, fmt.Errorf("request %s resp code is %d", url, resp.StatusCode)

0 commit comments

Comments
 (0)