Skip to content

feat: Add retry to API requests#141

Merged
kodiakhq[bot] merged 1 commit intomainfrom
feat/retry_requests
Mar 28, 2024
Merged

feat: Add retry to API requests#141
kodiakhq[bot] merged 1 commit intomainfrom
feat/retry_requests

Conversation

@erezrokah
Copy link
Copy Markdown
Member

Looks like this is the only way to inject the retry client, there's also oapi-codegen/oapi-codegen#150 which is in progress via oapi-codegen/oapi-codegen#156

@erezrokah erezrokah requested a review from hermanschaaf March 28, 2024 11:20
@erezrokah erezrokah changed the title feat: Support clients with retries feat: Add retry to API requests Mar 28, 2024
@@ -48,6 +49,7 @@ type ClientOption func(*Client) error

// Creates a new Client, with reasonable defaults
func NewClient(server string, opts ...ClientOption) (*Client, error) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also NewClientWithResponses but it wraps the call to NewClient


// Creates a new Client, with reasonable defaults
func NewClient(server string, opts ...ClientOption) (*Client, error) {
opts = append([]ClientOption{WithHTTPClient(retryablehttp.NewClient().StandardClient())}, opts...)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm prepending the option to allow consumers override it

Copy link
Copy Markdown
Contributor

@hermanschaaf hermanschaaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit complicated 🙃 ... hopefully we can find a simpler way to do this in the future

@erezrokah
Copy link
Copy Markdown
Member Author

Bit complicated 🙃 ... hopefully we can find a simpler way to do this in the future

Yeah I could add NewClientWithRetries as well, but it requires updating all consumers

@erezrokah erezrokah added the automerge Add to automerge PRs once requirements are met label Mar 28, 2024
@kodiakhq kodiakhq bot merged commit bf7b4e6 into main Mar 28, 2024
@kodiakhq kodiakhq bot deleted the feat/retry_requests branch March 28, 2024 11:28
kodiakhq bot pushed a commit that referenced this pull request Mar 28, 2024
🤖 I have created a release *beep* *boop*
---


## [1.9.0](v1.8.1...v1.9.0) (2024-03-28)


### Features

* Add retry to API requests ([#141](#141)) ([bf7b4e6](bf7b4e6))


### Bug Fixes

* Generate CloudQuery Go API Client from `spec.json` ([#139](#139)) ([0eb7391](0eb7391))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Add to automerge PRs once requirements are met

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants