Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk: Feature request for customizable client options #1118

Open
1 task done
wuxu92 opened this issue Nov 13, 2024 · 0 comments
Open
1 task done

sdk: Feature request for customizable client options #1118

wuxu92 opened this issue Nov 13, 2024 · 0 comments

Comments

@wuxu92
Copy link
Contributor

wuxu92 commented Nov 13, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Currently, the RequestOptions are generated by Pandora and cannot be customized by the method caller. For example, see managedhsms/method_createorupdate.go#L25-L34.

It would be great if we could modify these options to customize at least the ExpectedStatusCodes and RetryFunc in some scenarios. The default retryCheck returns true for 5xx responses, but for services like managed HSM, we should not retry on a 503 status code due to capacity check failure.

{
    "error": {
        "code": "503",
        "message": "Capacity check failed"
    }
}

Proposal

Since the SDK method signatures are defined and should not change, one way to pass custom information is through the ctx parameter. We can then apply them during the NewRequest method.

	ctx = context.WithValue(ctx, "request-options", func(opts *RequestOptions) {
		opts.RetryFunc = func() {xxx}
	})
	if err := client.ManagedHsmClient.CreateOrUpdateThenPoll(ctx, id, hsm); err != nil {
		return fmt.Errorf("creating %s: %+v", id, err)
	}

If this looks reasonable and acceptable, I'd be happy to submit a PR to add this feature.

Service Name

sdk

API Versions Required

N/A

References

No response

@wuxu92 wuxu92 changed the title sdk: Feature request of Supporting for customize client options sdk: Feature request for customizable client options Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant