Skip to content

Commit

Permalink
PORKBUN: increase req interval and retry on 503 (#3228)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom Limoncelli <[email protected]>
  • Loading branch information
imlonghao and tlimoncelli authored Dec 10, 2024
1 parent e774e2d commit de6afe2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions providers/porkbun/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,21 @@ func (c *porkbunProvider) post(endpoint string, params requestParams) ([]byte, e
// If request sending too fast, the server will fail with the following error:
// porkbun API error: Create error: We were unable to create the DNS record.
retry:
time.Sleep(500 * time.Millisecond)
time.Sleep(time.Second)
resp, err := client.Do(req)
if err != nil {
return []byte{}, err
}

bodyString, _ := io.ReadAll(resp.Body)

if resp.StatusCode == 202 {
if resp.StatusCode == 202 || resp.StatusCode == 503 {
retrycnt += 1
if retrycnt == 5 {
return bodyString, fmt.Errorf("rate limiting exceeded")
}
printer.Warnf("Rate limiting.. waiting for %d minute(s)\n", retrycnt)
time.Sleep(time.Minute * time.Duration(retrycnt))
printer.Warnf("Rate limiting.. waiting for %d second(s)\n", retrycnt*10)
time.Sleep(time.Second * time.Duration(retrycnt*10))
goto retry
}

Expand Down

0 comments on commit de6afe2

Please sign in to comment.