exoscale / egoscale

exoscale golang bindings
https://pkg.go.dev/github.com/exoscale/egoscale/v3
Apache License 2.0
31 stars 14 forks source link

v2: use hashicorp/go-retryablehttp as default http client #562

Closed kobajagi closed 2 years ago

kobajagi commented 2 years ago

This PR changes default v2 HTTP client to go-retryablehttp. This new library provides retry logic for HTTP server errors and network errors.

Debug logs for retries can be seen when running unit tests:

=== RUN   TestDefaultClient_Retry                                                                                      
2022/09/05 14:03:38 [DEBUG] GET http://127.0.0.1:42175                                                                 
2022/09/05 14:03:38 [DEBUG] GET http://127.0.0.1:42175 (status: 500): retrying in 1s (4 left)                          
2022/09/05 14:03:39 [DEBUG] GET http://127.0.0.1:42175 (status: 500): retrying in 2s (3 left)                          
--- PASS: TestDefaultClient_Retry (3.00s)

Because user-agent setter was implemented as http Transport (and would overwrite the new library logic), user-agent setter now works as oapi request editor.

shortcut-integration[bot] commented 2 years ago

This pull request has been linked to Shortcut Story #51744: egoscale v2: implement retry logic.

kobajagi commented 2 years ago

Had to replace io/ioutil library (with io) for lint to pass.